Return to array_multisort_natural_case.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_multisort() function : natural sorting case-sensitive 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 case-sensitive\n"; 12: 13: $a = array( 14: 'Second', 15: 'First.1', 16: 'First.2', 17: 'First.3', 18: 'Twentieth', 19: 'Tenth', 20: 'Third', 21: ); 22: 23: $b = array( 24: '2 a', 25: '1 bb 1', 26: '1 bB 2', 27: '1 BB 3', 28: '20 c', 29: '10 d', 30: '3 e', 31: ); 32: 33: array_multisort($b, SORT_NATURAL, $a); 34: 35: var_dump($a, $b); 36: 37: ?> 38: ===DONE=== 39: --EXPECTF-- 40: *** Testing array_multisort() : natural sorting case-sensitive 41: array(7) { 42: [0]=> 43: string(7) "First.3" 44: [1]=> 45: string(7) "First.2" 46: [2]=> 47: string(7) "First.1" 48: [3]=> 49: string(6) "Second" 50: [4]=> 51: string(5) "Third" 52: [5]=> 53: string(5) "Tenth" 54: [6]=> 55: string(9) "Twentieth" 56: } 57: array(7) { 58: [0]=> 59: string(6) "1 BB 3" 60: [1]=> 61: string(6) "1 bB 2" 62: [2]=> 63: string(6) "1 bb 1" 64: [3]=> 65: string(3) "2 a" 66: [4]=> 67: string(3) "3 e" 68: [5]=> 69: string(4) "10 d" 70: [6]=> 71: string(4) "20 c" 72: } 73: ===DONE===