1--TEST--
2Test array_map() function : usage variations - with recursive callback
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() by passing subarrays and recursive callback function
12 */
13
14echo "*** Testing array_map() : recursive callback function ***\n";
15
16// callback function
17function square_recur_single_array($var) {
18   if (is_array($var))
19     return array_map('square_recur_single_array', $var);
20   return $var * $var;
21}
22
23$array1 = array(1, array(2, 3, array(5)), array(4));
24
25var_dump( array_map('square_recur_single_array', $array1));
26
27echo "Done";
28?>
29--EXPECTF--
30*** Testing array_map() : recursive callback function ***
31array(3) {
32  [0]=>
33  int(1)
34  [1]=>
35  array(3) {
36    [0]=>
37    int(4)
38    [1]=>
39    int(9)
40    [2]=>
41    array(1) {
42      [0]=>
43      int(25)
44    }
45  }
46  [2]=>
47  array(1) {
48    [0]=>
49    int(16)
50  }
51}
52Done
53