Annotation of embedaddon/php/ext/standard/tests/array/array_map_variation19.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_map() function : usage variations - callback pass semantics
3: --FILE--
4: <?php
5: /* Prototype : array array_map ( callback $callback , array $arr1 [, array $... ] )
6: * Description: Applies the callback to the elements of the given arrays
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Test array_map() with a pass-by-value callback forced to behave as a pass-by-reference function.
12: */
13:
14: $arr1 = array('original.0', 'original.1');
15: $arr2 = array('original.0', 'original.1');
16:
17: function callback($a) {
18: $a = "changed";
19: }
20:
21: array_map('callback', $arr1);
22: var_dump($arr1);
23:
24: $ref =& $arr2[0];
25: array_map("callback", $arr2);
26: var_dump($arr2);
27: ?>
28: --EXPECTF--
29: array(2) {
30: [0]=>
31: string(10) "original.0"
32: [1]=>
33: string(10) "original.1"
34: }
35: array(2) {
36: [0]=>
37: &string(7) "changed"
38: [1]=>
39: string(10) "original.1"
40: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>