Annotation of embedaddon/php/ext/standard/tests/array/array_multisort_natural.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_multisort() function : natural sorting
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:
11: echo "*** Testing array_multisort() : natural sorting\n";
12:
13: $a = array(
14: 'Second',
15: 'First',
16: 'Twentieth',
17: 'Tenth',
18: 'Third',
19: );
20:
21: $b = array(
22: '2 a',
23: '1 b',
24: '20 c',
25: '10 d',
26: '3 e',
27: );
28:
29: array_multisort($b, SORT_NATURAL, $a);
30:
31: var_dump($a, $b);
32:
33: ?>
34: ===DONE===
35: --EXPECTF--
36: *** Testing array_multisort() : natural sorting
37: array(5) {
38: [0]=>
39: string(5) "First"
40: [1]=>
41: string(6) "Second"
42: [2]=>
43: string(5) "Third"
44: [3]=>
45: string(5) "Tenth"
46: [4]=>
47: string(9) "Twentieth"
48: }
49: array(5) {
50: [0]=>
51: string(3) "1 b"
52: [1]=>
53: string(3) "2 a"
54: [2]=>
55: string(3) "3 e"
56: [3]=>
57: string(4) "10 d"
58: [4]=>
59: string(4) "20 c"
60: }
61: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>