1--TEST-- 2Test array_diff_uassoc() function : usage variation - Comparing integers with strings containing 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_default_int = array(1, 2, 3); 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 integers and strings containing an integers --\n"; 27var_dump( array_diff_uassoc($arr_default_int, $arr_string_int, "key_compare_func") ); 28var_dump( array_diff_uassoc($arr_string_int, $arr_default_int, "key_compare_func") ); 29 30echo "\n-- Result of comparing integers and strings containing floating points --\n"; 31var_dump( array_diff_uassoc($arr_default_int, $arr_string_float, "key_compare_func") ); 32var_dump( array_diff_uassoc($arr_string_float, $arr_default_int, "key_compare_func") ); 33 34?> 35===DONE=== 36--EXPECTF-- 37*** Testing array_diff_uassoc() : usage variation *** 38 39-- Result of comparing integers and strings containing an integers -- 40array(1) { 41 [2]=> 42 int(3) 43} 44array(0) { 45} 46 47-- Result of comparing integers and strings containing floating points -- 48array(3) { 49 [0]=> 50 int(1) 51 [1]=> 52 int(2) 53 [2]=> 54 int(3) 55} 56array(2) { 57 [0]=> 58 string(4) "1.00" 59 ["1.00"]=> 60 string(4) "2.00" 61} 62===DONE=== 63