Return to array_diff_uassoc_variation5.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_diff_uassoc() function : usage variation - Comparing integers and floating point numbers 3: --FILE-- 4: <?php 5: /* Prototype : array array_diff_uassoc(array arr1, array arr2 [, array ...], callback key_comp_func) 6: * Description: Computes the difference of arrays with additional index check which is performed by a 7: * user supplied callback function 8: * Source code: ext/standard/array.c 9: */ 10: 11: echo "*** Testing array_diff_uassoc() : usage variation ***\n"; 12: 13: //Initialize variables 14: $arr_default_int = array(1, 2, 3, 4); 15: $arr_float = array(0 => 1.00, 1.00 => 2.00, 2.00 => 3.00, 3.00 => 4.00); 16: 17: 18: function key_compare_func($key1, $key2) 19: { 20: if ($key1 === $key2) { 21: return 0; 22: } 23: return ($key1 > $key2)? 1:-1; 24: } 25: 26: echo "\n-- Result of comparing integers and floating point numbers --\n"; 27: var_dump( array_diff_uassoc($arr_default_int, $arr_float, "key_compare_func") ); 28: var_dump( array_diff_uassoc($arr_float, $arr_default_int, "key_compare_func") ); 29: 30: ?> 31: ===DONE=== 32: --EXPECTF-- 33: *** Testing array_diff_uassoc() : usage variation *** 34: 35: -- Result of comparing integers and floating point numbers -- 36: array(0) { 37: } 38: array(0) { 39: } 40: ===DONE===