1--TEST--
2Test array_intersect_ukey() function : usage variation - Intersection of strings containing integer and float
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$arr1_string_int = array('0' => '1', '1' => '2');
14$arr2_string_int = array('0' => '1', '1' => '3');
15$arr1_string_float = array('0.00' => '1.00', '1.00' => '2.00');
16$arr2_string_float = array('0.00' => '1.00', '1.00' => '3.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 strings containing integers intersection --\n";
28var_dump( array_intersect_ukey($arr1_string_int, $arr2_string_int, 'key_compare_func') );
29
30echo "\n-- Result of strings containing floating points intersection --\n";
31var_dump( array_intersect_ukey($arr1_string_float, $arr2_string_float, 'key_compare_func') );
32
33echo "\n-- Result of strings containing integers and strings containing floating points intersection --\n";
34var_dump( array_intersect_ukey($arr1_string_int, $arr2_string_float, 'key_compare_func') );
35?>
36===DONE===
37--EXPECTF--
38*** Testing array_intersect_ukey() : usage variation ***
39
40-- Result of strings containing integers intersection --
41array(2) {
42  [0]=>
43  string(1) "1"
44  [1]=>
45  string(1) "2"
46}
47
48-- Result of strings containing floating points intersection --
49array(2) {
50  ["0.00"]=>
51  string(4) "1.00"
52  ["1.00"]=>
53  string(4) "2.00"
54}
55
56-- Result of strings containing integers and strings containing floating points intersection --
57array(2) {
58  [0]=>
59  string(1) "1"
60  [1]=>
61  string(1) "2"
62}
63===DONE===