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