Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_uassoc_variation8.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_uassoc() function : usage variation - arrays containing referenced variables
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: $ref_var = 'a';
14: $array1 = array('a', $ref_var);
15: $array2 = array('a' => 1, &$ref_var);
16:
17: echo "\n-- Testing array_intersect_uassoc() function with referenced variable \$ref_var has value '$ref_var' --\n";
18: var_dump( array_intersect_uassoc($array1, $array2, "strcasecmp") );
19:
20: // re-assign reference variable to different value
21: $ref_var = 10;
22: echo "\n-- Testing array_intersect_uassoc() function with referenced variable \$ref_var value changed to $ref_var --\n";
23: var_dump( array_intersect_uassoc($array1, $array2, "strcasecmp") );
24:
25: //When array are referenced
26: $array2 = &$array1;
27: echo "\n-- Testing array_intersect_uassoc() function when \$array2 is referencd to \$array1 --\n";
28: var_dump( array_intersect_uassoc($array1, $array2, "strcasecmp") );
29: ?>
30: ===DONE===
31: --EXPECTF--
32: *** Testing array_intersect_uassoc() : usage variation ***
33:
34: -- Testing array_intersect_uassoc() function with referenced variable $ref_var has value 'a' --
35: array(1) {
36: [0]=>
37: string(1) "a"
38: }
39:
40: -- Testing array_intersect_uassoc() function with referenced variable $ref_var value changed to 10 --
41: array(0) {
42: }
43:
44: -- Testing array_intersect_uassoc() function when $array2 is referencd to $array1 --
45: array(2) {
46: [0]=>
47: string(1) "a"
48: [1]=>
49: string(1) "a"
50: }
51: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>