1--TEST-- 2Test array_diff_uassoc() function : usage variation - Comparing floating points with strings having integers and float 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 11echo "*** Testing array_diff_uassoc() : usage variation ***\n"; 12 13//Initialize variables 14$arr_float = array(0 => 1.00, 1.00 => 2.00); 15$arr_string_int = array('1', '2'); 16$arr_string_float = array('0' => '1.00', '1.00' => '2.00'); 17 18function key_compare_func($key1, $key2) 19{ 20 if ($key1 === $key2) { 21 return 0; 22 } 23 return ($key1 > $key2)? 1:-1; 24} 25 26echo "\n-- Result of comparing floating points and strings containing integers --\n"; 27var_dump( array_diff_uassoc($arr_float, $arr_string_int, "key_compare_func") ); 28var_dump( array_diff_uassoc($arr_string_int, $arr_float, "key_compare_func") ); 29 30echo "\n-- Result of comparing floating points and strings containing floating point --\n"; 31var_dump( array_diff_uassoc($arr_float, $arr_string_float, "key_compare_func") ); 32var_dump( array_diff_uassoc($arr_string_float, $arr_float, "key_compare_func") ); 33 34?> 35===DONE=== 36--EXPECTF-- 37*** Testing array_diff_uassoc() : usage variation *** 38 39-- Result of comparing floating points and strings containing integers -- 40array(0) { 41} 42array(0) { 43} 44 45-- Result of comparing floating points and strings containing floating point -- 46array(2) { 47 [0]=> 48 float(1) 49 [1]=> 50 float(2) 51} 52array(2) { 53 [0]=> 54 string(4) "1.00" 55 ["1.00"]=> 56 string(4) "2.00" 57} 58===DONE=== 59