remove array_multisort and convert array_multisortN to use inout
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_splice_variation3.php
blob3918e8102462a4e113f86f6be602c75eb0f9275e
1 <?hh
2 /*
3 * proto array array_splice(array input, int offset [, int length [, array replacement]])
4 * Function is implemented in ext/standard/array.c
5 */
7 function test_splice ($offset, $length)
9 echo " - No replacement\n";
10 $input_array=array(0,1,2,3,4,5);
11 var_dump (array_splice (&$input_array,$offset,$length));
12 var_dump ($input_array);
13 echo " - With replacement\n";
14 $input_array=array(0,1,2,3,4,5);
15 var_dump (array_splice (&$input_array,$offset,$length,array ("A","B","C")));
16 var_dump ($input_array);
18 <<__EntryPoint>> function main(): void {
19 echo "*** array_splice() function : usage variations - lengths and offsets\n";
21 echo "absolute offset - absolute length - cut from beginning\n";
22 test_splice (0,2);
23 echo "absolute offset - absolute length - cut from middle\n";
24 test_splice (2,2);
25 echo "absolute offset - absolute length - cut from end\n";
26 test_splice (4,2);
27 echo "absolute offset - absolute length - attempt to cut past end\n";
28 test_splice (4,4);
29 echo "absolute offset - absolute length - cut everything\n";
30 test_splice (0,7);
31 echo "absolute offset - absolute length - cut nothing\n";
32 test_splice (3,0);
34 echo "absolute offset - relative length - cut from beginning\n";
35 test_splice (0,-4);
37 echo "absolute offset - relative length - cut from middle\n";
38 test_splice (2,-2);
40 echo "absolute offset - relative length - attempt to cut form before beginning \n";
41 test_splice (0,-7);
43 echo "absolute offset - relative length - cut nothing\n";
44 test_splice (2,-7);
46 echo "relative offset - absolute length - cut from beginning\n";
47 test_splice (-6,2);
49 echo "relative offset - absolute length - cut from middle\n";
50 test_splice (-4,2);
51 echo "relative offset - absolute length - cut from end\n";
52 test_splice (-2,2);
53 echo "relative offset - absolute length - attempt to cut past end\n";
54 test_splice (-2,4);
55 echo "relative offset - absolute length - cut everything\n";
56 test_splice (-6,6);
57 echo "relative offset - absolute length - cut nothing\n";
58 test_splice (-6,0);
60 echo "relative offset - relative length - cut from beginning\n";
61 test_splice (-6,-4);
63 echo "relative offset - relative length - cut from middle\n";
64 test_splice (-4,-2);
66 echo "relative offset - relative length - cut nothing\n";
67 test_splice (-4,-7);
68 echo "Done\n";