1--TEST-- 2Test array_multisort() function : usage variation - test sort order of all types 3--FILE-- 4<?php 5/* Prototype : bool array_multisort(array ar1 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]] [, array ar2 [, SORT_ASC|SORT_DESC [, SORT_REGULAR|SORT_NUMERIC|SORT_STRING|SORT_NATURAL|SORT_FLAG_CASE]], ...]) 6 * Description: Sort multiple arrays at once similar to how ORDER BY clause works in SQL 7 * Source code: ext/standard/array.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing array_multisort() : usage variation - test sort order of all types***\n"; 12 13// define some classes 14class classWithToString { 15 public function __toString() { 16 return "Class A object"; 17 } 18} 19 20class classWithoutToString { } 21 22$inputs = array( 23 'int 0' => 0, 24 'float -10.5' => -10.5, 25 array(), 26 'uppercase NULL' => NULL, 27 'lowercase true' => true, 28 'empty string DQ' => "", 29 'string DQ' => "string", 30 'instance of classWithToString' => new classWithToString(), 31 'instance of classWithoutToString' => new classWithoutToString(), 32 'undefined var' => @$undefined_var, 33); 34 35var_dump(array_multisort($inputs, SORT_NUMERIC)); 36var_dump($inputs); 37 38?> 39===DONE=== 40--EXPECTF-- 41*** Testing array_multisort() : usage variation - test sort order of all types*** 42 43Notice: Object of class classWithToString could not be converted to float in %sarray_multisort_variation9.php on line %d 44 45Notice: Object of class classWithToString could not be converted to float in %sarray_multisort_variation9.php on line %d 46 47Notice: Object of class classWithoutToString could not be converted to float in %sarray_multisort_variation9.php on line %d 48 49Notice: Object of class classWithoutToString could not be converted to float in %sarray_multisort_variation9.php on line %d 50bool(true) 51array(10) { 52 ["float -10.5"]=> 53 float(-10.5) 54 ["int 0"]=> 55 int(0) 56 [0]=> 57 array(0) { 58 } 59 ["uppercase NULL"]=> 60 NULL 61 ["empty string DQ"]=> 62 string(0) "" 63 ["string DQ"]=> 64 string(6) "string" 65 ["undefined var"]=> 66 NULL 67 ["lowercase true"]=> 68 bool(true) 69 ["instance of classWithToString"]=> 70 object(classWithToString)#1 (0) { 71 } 72 ["instance of classWithoutToString"]=> 73 object(classWithoutToString)#2 (0) { 74 } 75} 76===DONE=== 77