Annotation of embedaddon/php/ext/standard/tests/array/array_unshift_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_unshift() function : basic functionality - associative arrays for 'array' argument
3: --FILE--
4: <?php
5: /* Prototype : int array_unshift(array $array, mixed $var [, mixed ...])
6: * Description: Pushes elements onto the beginning of the array
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Testing array_unshift() by giving associative arrays for $array argument
12: */
13:
14: echo "*** Testing array_unshift() : basic functionality with associative array ***\n";
15:
16: // Initialise the array
17: $array = array('f' => "first", "s" => 'second', 1 => "one", 2 => 'two');
18:
19: // Calling array_unshift() with default argument
20: $temp_array = $array;
21: // returns element count in the resulting array after arguments are pushed to
22: // beginning of the given array
23: var_dump( array_unshift($temp_array, 10) );
24:
25: // dump the resulting array
26: var_dump($temp_array);
27:
28: // Calling array_unshift() with optional arguments
29: $temp_array = $array;
30: // returns element count in the resulting array after arguments are pushed to
31: // beginning of the given array
32: var_dump( array_unshift($temp_array, 222, "hello", 12.33) );
33:
34: // dump the resulting array
35: var_dump($temp_array);
36:
37: echo "Done";
38: ?>
39: --EXPECTF--
40: *** Testing array_unshift() : basic functionality with associative array ***
41: int(5)
42: array(5) {
43: [0]=>
44: int(10)
45: ["f"]=>
46: string(5) "first"
47: ["s"]=>
48: string(6) "second"
49: [1]=>
50: string(3) "one"
51: [2]=>
52: string(3) "two"
53: }
54: int(7)
55: array(7) {
56: [0]=>
57: int(222)
58: [1]=>
59: string(5) "hello"
60: [2]=>
61: float(12.33)
62: ["f"]=>
63: string(5) "first"
64: ["s"]=>
65: string(6) "second"
66: [3]=>
67: string(3) "one"
68: [4]=>
69: string(3) "two"
70: }
71: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>