1--TEST-- 2Test array_slice() function : usage variations - Pass different integers as $offset argument 3--FILE-- 4<?php 5/* 6 * Pass different integers as $offset argument to test how array_slice() behaves 7 */ 8 9echo "*** Testing array_slice() : usage variations ***\n"; 10 11$input = array ('one' => 1, 2 => 'two', 'three', 9 => 'nine', 'ten' => 10); 12 13for ($i = -7; $i <= 7; $i++) { 14 echo "\n-- \$offset is $i --\n"; 15 var_dump(array_slice($input, $i)); 16} 17echo "\n-- \$offset is maximum integer value --\n"; 18var_dump(array_slice($input, PHP_INT_MAX)); 19 20echo "\n-- \$offset is minimum integer value --\n"; 21var_dump(array_slice($input, -PHP_INT_MAX)); 22 23echo "Done"; 24?> 25--EXPECT-- 26*** Testing array_slice() : usage variations *** 27 28-- $offset is -7 -- 29array(5) { 30 ["one"]=> 31 int(1) 32 [0]=> 33 string(3) "two" 34 [1]=> 35 string(5) "three" 36 [2]=> 37 string(4) "nine" 38 ["ten"]=> 39 int(10) 40} 41 42-- $offset is -6 -- 43array(5) { 44 ["one"]=> 45 int(1) 46 [0]=> 47 string(3) "two" 48 [1]=> 49 string(5) "three" 50 [2]=> 51 string(4) "nine" 52 ["ten"]=> 53 int(10) 54} 55 56-- $offset is -5 -- 57array(5) { 58 ["one"]=> 59 int(1) 60 [0]=> 61 string(3) "two" 62 [1]=> 63 string(5) "three" 64 [2]=> 65 string(4) "nine" 66 ["ten"]=> 67 int(10) 68} 69 70-- $offset is -4 -- 71array(4) { 72 [0]=> 73 string(3) "two" 74 [1]=> 75 string(5) "three" 76 [2]=> 77 string(4) "nine" 78 ["ten"]=> 79 int(10) 80} 81 82-- $offset is -3 -- 83array(3) { 84 [0]=> 85 string(5) "three" 86 [1]=> 87 string(4) "nine" 88 ["ten"]=> 89 int(10) 90} 91 92-- $offset is -2 -- 93array(2) { 94 [0]=> 95 string(4) "nine" 96 ["ten"]=> 97 int(10) 98} 99 100-- $offset is -1 -- 101array(1) { 102 ["ten"]=> 103 int(10) 104} 105 106-- $offset is 0 -- 107array(5) { 108 ["one"]=> 109 int(1) 110 [0]=> 111 string(3) "two" 112 [1]=> 113 string(5) "three" 114 [2]=> 115 string(4) "nine" 116 ["ten"]=> 117 int(10) 118} 119 120-- $offset is 1 -- 121array(4) { 122 [0]=> 123 string(3) "two" 124 [1]=> 125 string(5) "three" 126 [2]=> 127 string(4) "nine" 128 ["ten"]=> 129 int(10) 130} 131 132-- $offset is 2 -- 133array(3) { 134 [0]=> 135 string(5) "three" 136 [1]=> 137 string(4) "nine" 138 ["ten"]=> 139 int(10) 140} 141 142-- $offset is 3 -- 143array(2) { 144 [0]=> 145 string(4) "nine" 146 ["ten"]=> 147 int(10) 148} 149 150-- $offset is 4 -- 151array(1) { 152 ["ten"]=> 153 int(10) 154} 155 156-- $offset is 5 -- 157array(0) { 158} 159 160-- $offset is 6 -- 161array(0) { 162} 163 164-- $offset is 7 -- 165array(0) { 166} 167 168-- $offset is maximum integer value -- 169array(0) { 170} 171 172-- $offset is minimum integer value -- 173array(5) { 174 ["one"]=> 175 int(1) 176 [0]=> 177 string(3) "two" 178 [1]=> 179 string(5) "three" 180 [2]=> 181 string(4) "nine" 182 ["ten"]=> 183 int(10) 184} 185Done 186