1--TEST--
2Test array_chunk() function : usage variations - array with diff. sub arrays
3--FILE--
4<?php
5/*
6* Testing array_chunk() function - input array containing different sub arrays
7*/
8
9echo "*** Testing array_chunk() : usage variations ***\n";
10
11$size = 2;
12
13// input array
14$input_array = array (
15  "array1" => array(),
16  "array2" => array(1, 2, 3),
17  "array3" =>  array(1)
18);
19
20echo "\n-- Testing array_chunk() by supplying an array containing different sub arrays & 'preserve_key' as default --\n";
21var_dump( array_chunk($input_array, $size) );
22
23echo "\n-- Testing array_chunk() by supplying an array containing different sub arrays & 'preserve_key' = true --\n";
24var_dump( array_chunk($input_array, $size, true) );
25
26echo "\n-- Testing array_chunk() by supplying an array containing different sub arrays & 'preserve_key' = false --\n";
27var_dump( array_chunk($input_array, $size, false) );
28
29echo "Done";
30?>
31--EXPECT--
32*** Testing array_chunk() : usage variations ***
33
34-- Testing array_chunk() by supplying an array containing different sub arrays & 'preserve_key' as default --
35array(2) {
36  [0]=>
37  array(2) {
38    [0]=>
39    array(0) {
40    }
41    [1]=>
42    array(3) {
43      [0]=>
44      int(1)
45      [1]=>
46      int(2)
47      [2]=>
48      int(3)
49    }
50  }
51  [1]=>
52  array(1) {
53    [0]=>
54    array(1) {
55      [0]=>
56      int(1)
57    }
58  }
59}
60
61-- Testing array_chunk() by supplying an array containing different sub arrays & 'preserve_key' = true --
62array(2) {
63  [0]=>
64  array(2) {
65    ["array1"]=>
66    array(0) {
67    }
68    ["array2"]=>
69    array(3) {
70      [0]=>
71      int(1)
72      [1]=>
73      int(2)
74      [2]=>
75      int(3)
76    }
77  }
78  [1]=>
79  array(1) {
80    ["array3"]=>
81    array(1) {
82      [0]=>
83      int(1)
84    }
85  }
86}
87
88-- Testing array_chunk() by supplying an array containing different sub arrays & 'preserve_key' = false --
89array(2) {
90  [0]=>
91  array(2) {
92    [0]=>
93    array(0) {
94    }
95    [1]=>
96    array(3) {
97      [0]=>
98      int(1)
99      [1]=>
100      int(2)
101      [2]=>
102      int(3)
103    }
104  }
105  [1]=>
106  array(1) {
107    [0]=>
108    array(1) {
109      [0]=>
110      int(1)
111    }
112  }
113}
114Done
115