1--TEST--
2Test array_chunk() function : usage variations - references
3--FILE--
4<?php
5/* Prototype  : array array_chunk(array $array, int $size [, bool $preserve_keys])
6 * Description: Split array into chunks
7 *            : Chunks an array into size large chunks
8 * Source code: ext/standard/array.c
9*/
10
11/*
12 * Testing array_chunk() function with following conditions
13 *   1. input array containing references
14*/
15
16echo "*** Testing array_chunk() : usage variations ***\n";
17
18$size = 2;
19
20echo "\n-- Testing array_chunk(), input array containing references \n";
21
22$numbers=array(1, 2, 3, 4);
23// reference array
24$input_array = array (
25  "one" => &$numbers[0],
26  "two" => &$numbers[1],
27  "three" => &$numbers[2],
28  "four" => &$numbers[3]
29);
30
31var_dump( array_chunk($input_array, $size) );
32var_dump( array_chunk($input_array, $size, true) );
33var_dump( array_chunk($input_array, $size, false) );
34
35echo "Done";
36?>
37--EXPECT--
38*** Testing array_chunk() : usage variations ***
39
40-- Testing array_chunk(), input array containing references
41array(2) {
42  [0]=>
43  array(2) {
44    [0]=>
45    &int(1)
46    [1]=>
47    &int(2)
48  }
49  [1]=>
50  array(2) {
51    [0]=>
52    &int(3)
53    [1]=>
54    &int(4)
55  }
56}
57array(2) {
58  [0]=>
59  array(2) {
60    ["one"]=>
61    &int(1)
62    ["two"]=>
63    &int(2)
64  }
65  [1]=>
66  array(2) {
67    ["three"]=>
68    &int(3)
69    ["four"]=>
70    &int(4)
71  }
72}
73array(2) {
74  [0]=>
75  array(2) {
76    [0]=>
77    &int(1)
78    [1]=>
79    &int(2)
80  }
81  [1]=>
82  array(2) {
83    [0]=>
84    &int(3)
85    [1]=>
86    &int(4)
87  }
88}
89Done
90