1--TEST-- 2Test array_intersect_ukey() function : usage variation - Intersection of strings containing integer and float 3--FILE-- 4<?php 5echo "*** Testing array_intersect_ukey() : usage variation ***\n"; 6 7//Initialize variables 8$arr1_string_int = array('0' => '1', '1' => '2'); 9$arr2_string_int = array('0' => '1', '1' => '3'); 10$arr1_string_float = array('0.00' => '1.00', '1.00' => '2.00'); 11$arr2_string_float = array('0.00' => '1.00', '1.00' => '3.00'); 12 13//Call back function 14function key_compare_func($key1, $key2) 15{ 16 if ($key1 == $key2) 17 return 0; 18 else 19 return ($key1 > $key2)? 1:-1; 20} 21 22echo "\n-- Result of strings containing integers intersection --\n"; 23var_dump( array_intersect_ukey($arr1_string_int, $arr2_string_int, 'key_compare_func') ); 24 25echo "\n-- Result of strings containing floating points intersection --\n"; 26var_dump( array_intersect_ukey($arr1_string_float, $arr2_string_float, 'key_compare_func') ); 27 28echo "\n-- Result of strings containing integers and strings containing floating points intersection --\n"; 29var_dump( array_intersect_ukey($arr1_string_int, $arr2_string_float, 'key_compare_func') ); 30?> 31--EXPECT-- 32*** Testing array_intersect_ukey() : usage variation *** 33 34-- Result of strings containing integers intersection -- 35array(2) { 36 [0]=> 37 string(1) "1" 38 [1]=> 39 string(1) "2" 40} 41 42-- Result of strings containing floating points intersection -- 43array(2) { 44 ["0.00"]=> 45 string(4) "1.00" 46 ["1.00"]=> 47 string(4) "2.00" 48} 49 50-- Result of strings containing integers and strings containing floating points intersection -- 51array(2) { 52 [0]=> 53 string(1) "1" 54 [1]=> 55 string(1) "2" 56} 57