import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / sort_variation3.php
blob3e0e7f76d06fdc6f5e0b3d57b451a82aa6145757
1 <?php
2 /* Prototype : bool sort ( array &$array [, int $sort_flags] )
3 * Description: This function sorts an array.
4 Elements will be arranged from lowest to highest when this function has completed.
5 * Source code: ext/standard/array.c
6 */
8 /*
9 * Testing sort() by providing different integer/float value arrays for $array argument
10 * with following flag values
11 * 1. flag value as defualt
12 * 2. SORT_REGULAR - compare items normally
13 * 3. SORT_NUMERIC - compare items numerically
14 * 4. SORT_STRING - compare items as strings
17 echo "*** Testing sort() : usage variations ***\n";
19 // group of various arrays
20 $various_arrays = array (
21 // negative/posative integers array
22 array(11, -11, 21, -21, 31, -31, 0, 41, -41),
24 // float value array
25 array(10.5, -10.5, 10.5e2, 10.6E-2, .5, .01, -.1),
27 // mixed value array
28 array(.0001, .0021, -.01, -1, 0, .09, 2, -.9, 10.6E-2, -10.6E-2, 33),
30 // array values contains minimum and maximum ranges
31 array(2147483647, 2147483648, -2147483647, -2147483648, -0, 0, -2147483649)
34 // set of possible flag values
35 $flag_value = array("SORT_REGULAR" => SORT_REGULAR, "SORT_NUMERIC" => SORT_NUMERIC);
37 $count = 1;
38 echo "\n-- Testing sort() by supplying various integer/float arrays --\n";
40 // loop through to test sort() with different arrays
41 foreach ($various_arrays as $array) {
42 echo "\n-- Iteration $count --\n";
44 echo "- With Defualt sort flag -\n";
45 $temp_array = $array;
46 var_dump(sort($temp_array) );
47 var_dump($temp_array);
49 // loop through $flag_value array and setting all possible flag values
50 foreach($flag_value as $key => $flag){
51 echo "- Sort flag = $key -\n";
52 $temp_array = $array;
53 var_dump(sort($temp_array, $flag) );
54 var_dump($temp_array);
56 $count++;
59 echo "Done\n";