1--TEST--
2Test array_push() function : usage variations - multidimensional arrays
3--FILE--
4<?php
5/* Prototype  : int array_push(array $stack, mixed $var [, mixed $...])
6 * Description: Pushes elements onto the end of the array
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Test array_push when passed:
12 * 1. an array as $var arg
13 * 2. as sub-array as $stack arg
14 */
15
16echo "*** Testing array_push() : usage variations ***\n";
17
18echo "\n-- Pass array as \$var argument --\n";
19$array = array(1, 2, 3);
20$sub_array = array('one', 'two');
21var_dump(array_push($array, $sub_array));
22var_dump($array);
23
24echo "\n-- Pass sub-array as \$stack argument --\n";
25var_dump(array_push($array[3], 'a'));
26var_dump($array);
27
28echo "Done";
29?>
30--EXPECTF--
31*** Testing array_push() : usage variations ***
32
33-- Pass array as $var argument --
34int(4)
35array(4) {
36  [0]=>
37  int(1)
38  [1]=>
39  int(2)
40  [2]=>
41  int(3)
42  [3]=>
43  array(2) {
44    [0]=>
45    string(3) "one"
46    [1]=>
47    string(3) "two"
48  }
49}
50
51-- Pass sub-array as $stack argument --
52int(3)
53array(4) {
54  [0]=>
55  int(1)
56  [1]=>
57  int(2)
58  [2]=>
59  int(3)
60  [3]=>
61  array(3) {
62    [0]=>
63    string(3) "one"
64    [1]=>
65    string(3) "two"
66    [2]=>
67    string(1) "a"
68  }
69}
70Done
71