2 /* Prototype : proto bool asort(array &array_arg [, 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
9 * Testing asort() by providing different unexpected values for flag argument
12 echo "*** Testing asort() : usage variations ***\n";
14 //get an unset variable
19 $fp = fopen(__FILE__
, "r");
21 // temperory array for checking unexpected behavior
22 $unsorted_values = array(1 => 10, 2 => 2, 3 => 45);
24 //array of values to iterate over
25 $unexpected_values = array(
56 /*16*/ new stdclass(),
59 /*17*/ @undefined_var
,
69 // loop though each element of the array and check the working of asort()
70 // when $flag arugment is supplied with different values from $unexpected_values
71 echo "\n-- Testing asort() by supplying different unexpected values for 'sort_flags' argument --\n";
74 for($index = 0; $index < count($unexpected_values); $index ++
) {
75 echo "-- Iteration $counter --\n";
76 $value = $unexpected_values [$index];
77 $temp_array = $unsorted_values;
78 var_dump( asort($temp_array, $value) );
79 var_dump($temp_array);