1--TEST--
2Test array_walk() function : usage variations - anonymous callback function
3--FILE--
4<?php
5/*
6* Passing anonymous(run-time) callback function with following variations:
7*   with one parameter
8*   two parameters
9*   three parameters
10*   extra parameters
11*   without parameters
12*/
13
14echo "*** Testing array_walk() : anonymous function as callback ***\n";
15
16$input = array(2, 5, 10, 0);
17
18echo "-- Anonymous function with one argument --\n";
19var_dump( array_walk($input, function($value) { var_dump($value); echo "\n"; }));
20
21echo "-- Anonymous function with two arguments --\n";
22var_dump( array_walk($input, function($value, $key) { var_dump($key); var_dump($value); echo "\n"; }));
23
24echo "-- Anonymous function with three arguments --\n";
25var_dump( array_walk($input, function($value, $key, $user_data) { var_dump($key); var_dump($value); var_dump($user_data); echo "\n"; }, 10));
26
27echo "-- Anonymous function with null argument --\n";
28var_dump( array_walk( $input, function() { echo "1\n"; }));
29echo "Done"
30?>
31--EXPECT--
32*** Testing array_walk() : anonymous function as callback ***
33-- Anonymous function with one argument --
34int(2)
35
36int(5)
37
38int(10)
39
40int(0)
41
42bool(true)
43-- Anonymous function with two arguments --
44int(0)
45int(2)
46
47int(1)
48int(5)
49
50int(2)
51int(10)
52
53int(3)
54int(0)
55
56bool(true)
57-- Anonymous function with three arguments --
58int(0)
59int(2)
60int(10)
61
62int(1)
63int(5)
64int(10)
65
66int(2)
67int(10)
68int(10)
69
70int(3)
71int(0)
72int(10)
73
74bool(true)
75-- Anonymous function with null argument --
761
771
781
791
80bool(true)
81Done
82