Return to uksort_basic.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test uksort(): basic functionality 3: --FILE-- 4: <?php 5: /* 6: * proto bool uksort ( array &$array, callback $cmp_function ) 7: * Function is implemented in ext/standard/array.c 8: */ 9: function cmp($a, $b) { 10: if ($a == $b) { 11: return 0; 12: } 13: return ($a < $b) ? -1 : 1; 14: } 15: $a = array(3, 2, 5, 6, 1); 16: uasort($a, "cmp"); 17: foreach($a as $key => $value) { 18: echo "$key: $value\n"; 19: } 20: ?> 21: --EXPECT-- 22: 4: 1 23: 1: 2 24: 0: 3 25: 2: 5 26: 3: 6