Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_uassoc_variation7.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_uassoc() function : usage variation - Intersection of strings containing integers, float
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: $arr1_string_int = array('1', '2');
14: $arr2_string_int = array('1', '3');
15: $arr1_string_float = array('1.00', '2.00');
16: $arr2_string_float = array('1.00', '3.00');
17:
18: function key_compare_func($a, $b)
19: {
20: if ($a === $b) {
21: return 0;
22: }
23: return ($a > $b)? 1:-1;
24: }
25:
26: echo "\n-- Result of strings containing integers intersection --\n";
27: var_dump( array_intersect_uassoc($arr1_string_int, $arr2_string_int, "key_compare_func") );
28:
29: echo "\n-- Result of strings containing floating points intersection --\n";
30: var_dump( array_intersect_uassoc($arr1_string_float, $arr2_string_float, "key_compare_func") );
31:
32: echo "\n-- Result of strings containing integers and strings containing floating points intersection --\n";
33: var_dump( array_intersect_uassoc($arr1_string_int, $arr2_string_float, "key_compare_func") );
34: ?>
35: ===DONE===
36: --EXPECTF--
37: *** Testing array_intersect_uassoc() : usage variation ***
38:
39: -- Result of strings containing integers intersection --
40: array(1) {
41: [0]=>
42: string(1) "1"
43: }
44:
45: -- Result of strings containing floating points intersection --
46: array(1) {
47: [0]=>
48: string(4) "1.00"
49: }
50:
51: -- Result of strings containing integers and strings containing floating points intersection --
52: array(0) {
53: }
54: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>