1--TEST-- 2Test uasort() function : usage variations - built-in function as 'cmp_function' 3--FILE-- 4<?php 5/* 6* Passing different built-in library functions in place of 'cmp_function' 7* valid comparison functions: strcmp() & strcasecmp() 8*/ 9 10echo "*** Testing uasort() : built in function as 'cmp_function' ***\n"; 11// Initializing variables 12$array_arg = array("b" => "Banana", "m" => "Mango", "a" => "apple", "p" => "Pineapple", "o" => "orange"); 13$builtin_fun_arg = $array_arg; 14$languageConstruct_fun_arg = $array_arg; 15 16// Testing library functions as comparison function 17echo "-- Testing uasort() with built-in 'cmp_function': strcasecmp() --\n"; 18var_dump( uasort($builtin_fun_arg, 'strcasecmp') ); // expecting: bool(true) 19var_dump($builtin_fun_arg); 20 21echo "-- Testing uasort() with built-in 'cmp_function': strcmp() --\n"; 22var_dump( uasort($array_arg, 'strcmp') ); // expecting: bool(true) 23var_dump($array_arg); 24 25echo "Done" 26?> 27--EXPECT-- 28*** Testing uasort() : built in function as 'cmp_function' *** 29-- Testing uasort() with built-in 'cmp_function': strcasecmp() -- 30bool(true) 31array(5) { 32 ["a"]=> 33 string(5) "apple" 34 ["b"]=> 35 string(6) "Banana" 36 ["m"]=> 37 string(5) "Mango" 38 ["o"]=> 39 string(6) "orange" 40 ["p"]=> 41 string(9) "Pineapple" 42} 43-- Testing uasort() with built-in 'cmp_function': strcmp() -- 44bool(true) 45array(5) { 46 ["b"]=> 47 string(6) "Banana" 48 ["m"]=> 49 string(5) "Mango" 50 ["p"]=> 51 string(9) "Pineapple" 52 ["a"]=> 53 string(5) "apple" 54 ["o"]=> 55 string(6) "orange" 56} 57Done 58