import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / asort_variation8.php
blob91b7194685e3be8caf0ee2dc53deb9607d8b0d78
1 <?php
2 /* Prototype : bool asort ( array &$array [, int $sort_flags] )
3 * Description: Sort an array and maintain index association.
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 asort() by providing arrays contains sub arrays for $array argument with flowing flag values
10 * flag value as default
11 * SORT_REGULAR - compare items normally
12 * Note: arrays are sorted based on total count of elements inside it, when all the elements are arrays
15 echo "*** Testing asort() : usage variations ***\n";
17 // array of arrays
18 $various_arrays = array (
19 // null array
20 "array[0]" => array(),
22 // array contains null sub array
23 "array[1]" => array( "sub_array[1][0]" => array() ),
25 // array of arrays along with some values
26 "array[2]" => array("data[2,0]" => 44, "data[2,1]" => 11, "sub_array[2][0] " => array(64,61) ),
28 // array contains sub arrays
29 "array[3]" => array ( "sub_array[3][0]" => array(33,-5,6), "sub_array[3][1]" => array(11),
30 "sub_array[3][2]" => array(22,-55), "sub_array[3][3]" => array() )
34 $count = 1;
35 echo "\n-- Testing asort() by supplying various arrays containing sub arrays --\n";
37 // loop through to test asort() with different arrays
38 foreach ($various_arrays as $array) {
40 echo "\n-- Iteration $count --\n";
41 // testing asort() function by supplying different arrays, flag value is default
42 echo "- With default sort_flag -\n";
43 $temp_array = $array;
44 var_dump(asort($temp_array) );
45 var_dump($temp_array);
47 // testing asort() function by supplying different arrays, flag value = SORT_REGULAR
48 echo "- Sort_flag = SORT_REGULAR -\n";
49 $temp_array = $array;
50 var_dump(asort($temp_array, SORT_REGULAR) );
51 var_dump($temp_array);
52 $count++;
55 echo "Done\n";