Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_uassoc_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_uassoc() function : usage variation - Intersection of floating points with strings.
3: --FILE--
4: <?php
5: /* Prototype : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
6: * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
7: * Source code: ext/standard/array.c
8: */
9:
10: echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
11:
12: //Initialize variables
13: $arr_float = array(0 => 1.00, 1.00 => 2.00);
14: $arr_string = array('1', '2', '3');
15: $arr_string_float = array('1.00', '2.00');
16:
17: function key_compare_func($a, $b)
18: {
19: if ($a === $b) {
20: return 0;
21: }
22: return ($a > $b)? 1:-1;
23: }
24:
25: echo "\n-- Result of floating points and strings containing integers intersection --\n";
26: var_dump( array_intersect_uassoc($arr_float, $arr_string, "key_compare_func") );
27:
28: echo "\n-- Result of floating points and strings containing floating point intersection --\n";
29: var_dump( array_intersect_uassoc($arr_float, $arr_string_float, "key_compare_func") );
30: ?>
31: ===DONE===
32: --EXPECTF--
33: *** Testing array_intersect_uassoc() : usage variation ***
34:
35: -- Result of floating points and strings containing integers intersection --
36: array(2) {
37: [0]=>
38: float(1)
39: [1]=>
40: float(2)
41: }
42:
43: -- Result of floating points and strings containing floating point intersection --
44: array(0) {
45: }
46: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>