Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_ukey_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_ukey() function : usage variation - Intersection of floating points with 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:
10: echo "*** Testing array_intersect_ukey() : usage variation ***\n";
11:
12: //Initialize variables
13: $arr_float = array(0.00 => 1.00, 1.00 => 2.00);
14: $arr_string = array('0' => '1', '1' => '2', '2' => '3');
15: $arr_string_float = array('0.00' => '1.00', '1.00' => '2.00');
16:
17: //Call back function
18: function key_compare_func($key1, $key2)
19: {
20: if ($key1 == $key2)
21: return 0;
22: else
23: return ($key1 > $key2)? 1:-1;
24: }
25:
26: echo "\n-- Result of floating points and strings containing integers intersection --\n";
27: var_dump( array_intersect_ukey($arr_float, $arr_string, 'key_compare_func') );
28:
29: echo "\n-- Result of floating points and strings containing floating point intersection --\n";
30: var_dump( array_intersect_ukey($arr_float, $arr_string_float, 'key_compare_func') );
31: ?>
32: ===DONE===
33: --EXPECTF--
34: *** Testing array_intersect_ukey() : usage variation ***
35:
36: -- Result of floating points and strings containing integers intersection --
37: array(2) {
38: [0]=>
39: float(1)
40: [1]=>
41: float(2)
42: }
43:
44: -- Result of floating points and strings containing floating point intersection --
45: array(2) {
46: [0]=>
47: float(1)
48: [1]=>
49: float(2)
50: }
51: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>