1--TEST--
2Test array_walk() function : usage variations - 'input' argument containing reference variables
3--FILE--
4<?php
5/* Prototype  : bool array_walk(array $input, string $funcname [, mixed $userdata])
6 * Description: Apply a user function to every member of an array
7 * Source code: ext/standard/array.c
8*/
9
10/*
11 * Testing array_walk() with an array having reference variables
12*/
13
14echo "*** Testing array_walk() : array with references ***\n";
15
16$value1 = 10;
17$value2 = -20;
18$value3 = &$value1;
19$value4 = 50;
20
21// 'input' array containing references to above variables
22$input = array(&$value1, &$value2, -35, &$value3, 0, &$value4);
23
24// callback function
25/* Prototype : callback(int $value, mixed $key)
26 * Parameters : $value - values in given input array
27 *              $key - keys in given input array
28 * Description : function checks for the value whether positive or negative and displays according to that
29 */
30function callback($value, $key)
31{
32   // dump the arguments to check that they are passed
33   // with proper type
34   var_dump($key);  // key
35   var_dump($value); // value
36   echo "\n"; // new line to separate the output between each element
37}
38
39var_dump( array_walk($input, "callback"));
40
41echo "Done"
42?>
43--EXPECT--
44*** Testing array_walk() : array with references ***
45int(0)
46int(10)
47
48int(1)
49int(-20)
50
51int(2)
52int(-35)
53
54int(3)
55int(10)
56
57int(4)
58int(0)
59
60int(5)
61int(50)
62
63bool(true)
64Done
65