Revert "make hphpc able to use ini files"
[hiphop-php.git] / hphp / test / zend / bad / ext / standard / tests / array / ksort_variation5.php
blob5be15760741ed41fa7b7084a1d2a02472f231254
1 <?php
2 /* Prototype : bool ksort ( 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 ksort() by providing array of string values for $array argument with
9 * following flag values:
10 * 1.flag value as defualt
11 * 2.SORT_REGULAR - compare items normally
12 * 3.SORT_STRING - compare items as strings
15 echo "*** Testing ksort() : usage variations ***\n";
17 $various_arrays = array (
18 // diff. escape sequence chars with key values
19 array ( null => null, NULL => NULL, "\a" => "\a", "\cx" => "\cx", "\e" => "\e",
20 "\f" => "\f", "\n" =>"\n", "\r" => "\r", "\t" => "\t", "\xhh" => "\xhh",
21 "\ddd" => "\ddd", "\v" => "\v"
24 // array containing different strings with key values
25 array ( 'Lemon' => "lemoN", 'o' => "Orange", 'B' => "banana", 'Apple' => "apple", 'te' => "Test",
26 't' => "TTTT", 'T' => "ttt", 'W' => "ww", 'X' => "x", 'x' => "X", 'O' => "oraNGe",
27 'B' => "BANANA"
31 $flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING);
33 $count = 1;
34 echo "\n-- Testing ksort() by supplying various string arrays --\n";
36 // loop through to test ksort() with different arrays
37 foreach ($various_arrays as $array) {
38 echo "\n-- Iteration $count --\n";
40 echo "- With defualt sort flag -\n";
41 $temp_array = $array;
42 var_dump(ksort($temp_array) ); // expecting : bool(true)
43 var_dump($temp_array);
45 // loop through $flags array and call ksort() with all possible sort flag values
46 foreach($flags as $key => $flag){
47 echo "- Sort flag = $key -\n";
48 $temp_array = $array;
49 var_dump(ksort($temp_array, $flag) ); // expecting : bool(true)
50 var_dump($temp_array);
52 $count++;
55 echo "Done\n";