Fix build following D59537433
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / krsort_variation7.php
blob1e03d77cf20cbeee7fc2ce8f1a419add6c59c3fd
1 <?hh
2 /* Prototype : bool krsort ( array &$array [, int $sort_flags] )
3 * Description: Sort an array by key, maintaining key to data correlation
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * testing krsort() by providing arrays contains sub arrays for $array argument
9 * with flowing flag values
10 * 1.flag value as defualt
11 * 2.SORT_REGULAR - compare items normally
13 <<__EntryPoint>> function main(): void {
14 echo "*** Testing krsort() : usage variations ***\n";
16 // array with diff sub arrays to be sorted
17 $various_arrays = dict[
18 // null array
19 1 => vec[],
21 // array contains null sub array
22 2 => dict[ 1 => vec[] ],
24 // array of arrays along with some values
25 3 => dict[4 => 44, 1 => 11, 3 => vec[64,61] ],
27 // array contains sub arrays
28 4 => dict[ 3 => vec[33,-5,6], 1 => vec[11],
29 2 => vec[22,-55], 0 => vec[] ]
33 $count = 1;
34 echo "\n-- Testing krsort() by supplying various arrays containing sub arrays --\n";
36 // loop through to test krsort() with different arrays
37 foreach ($various_arrays as $array) {
39 echo "\n-- Iteration $count --\n";
40 echo "- With defualt sort flag -\n";
41 $temp_array = $array;
42 var_dump( krsort(inout $temp_array) );
43 var_dump($temp_array);
45 echo "- Sort flag = SORT_REGULAR -\n";
46 $temp_array = $array;
47 var_dump( krsort(inout $temp_array, SORT_REGULAR) );
48 var_dump($temp_array);
49 $count++;
52 echo "Done\n";