1--TEST-- 2Test array_intersect_ukey() function : usage variation - Intersection of integers with floats and strings. 3--FILE-- 4<?php 5/* Prototype : array array_intersect_ukey(array arr1, array arr2 [, array ...], callback key_compare_func) 6 * Description: Computes the intersection of arrays using a callback function on the keys for comparison. 7 * Source code: ext/standard/array.c 8 */ 9 10echo "*** Testing array_intersect_ukey() : usage variation ***\n"; 11 12//Initialize variables 13$arr_default_int = array(1, 2 ); 14$arr_float = array(0 => 1.00, 1.00 => 2.00, 2.00 => 3.00); 15$arr_string = array('0' => '1', '1' => '2', '2' => '3'); 16$arr_string_float = array('0.00' => '1.00', '1.00' => '2.00'); 17 18//Call back function 19function key_compare_func($key1, $key2) 20{ 21 if ($key1 == $key2) 22 return 0; 23 else 24 return ($key1 > $key2)? 1:-1; 25} 26 27echo "\n-- Result of integers and floating point intersection --\n"; 28var_dump( array_intersect_ukey($arr_default_int, $arr_float, "key_compare_func") ); 29 30echo "\n-- Result of integers and strings containing integers intersection --\n"; 31var_dump( array_intersect_ukey($arr_default_int, $arr_string, "key_compare_func") ); 32 33echo "\n-- Result of integers and strings containing floating points intersection --\n"; 34var_dump( array_intersect_ukey($arr_default_int, $arr_string_float, "key_compare_func") ); 35?> 36===DONE=== 37--EXPECT-- 38*** Testing array_intersect_ukey() : usage variation *** 39 40-- Result of integers and floating point intersection -- 41array(2) { 42 [0]=> 43 int(1) 44 [1]=> 45 int(2) 46} 47 48-- Result of integers and strings containing integers intersection -- 49array(2) { 50 [0]=> 51 int(1) 52 [1]=> 53 int(2) 54} 55 56-- Result of integers and strings containing floating points intersection -- 57array(2) { 58 [0]=> 59 int(1) 60 [1]=> 61 int(2) 62} 63===DONE=== 64