Annotation of embedaddon/php/ext/standard/tests/array/array_multisort_variation9.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test array_multisort() function : usage variation - test sort order of all types
3: --FILE--
4: <?php
1.1.1.2 ! misho 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]], ...])
1.1 misho 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:
11: echo "*** Testing array_multisort() : usage variation - test sort order of all types***\n";
12:
13: // define some classes
14: class classWithToString {
15: public function __toString() {
16: return "Class A object";
17: }
18: }
19:
20: class 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:
35: var_dump(array_multisort($inputs, SORT_NUMERIC));
36: var_dump($inputs);
37:
38: ?>
39: ===DONE===
40: --EXPECTF--
41: *** Testing array_multisort() : usage variation - test sort order of all types***
42:
43: Notice: Object of class classWithToString could not be converted to double in %sarray_multisort_variation9.php on line %d
44:
45: Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
46:
47: Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
48:
49: Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
50:
51: Notice: Object of class classWithoutToString could not be converted to double in %sarray_multisort_variation9.php on line %d
52: bool(true)
53: array(10) {
54: ["float -10.5"]=>
55: float(-10.5)
56: ["string DQ"]=>
57: string(6) "string"
58: ["undefined var"]=>
59: NULL
60: ["empty string DQ"]=>
61: string(0) ""
62: ["uppercase NULL"]=>
63: NULL
64: ["int 0"]=>
65: int(0)
66: [0]=>
67: array(0) {
68: }
69: ["instance of classWithoutToString"]=>
70: object(classWithoutToString)#2 (0) {
71: }
72: ["lowercase true"]=>
73: bool(true)
74: ["instance of classWithToString"]=>
75: object(classWithToString)#1 (0) {
76: }
77: }
78: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>