1--TEST--
2Test array_map() function : usage variations - callback function with different return types
3--FILE--
4<?php
5/*
6 * Test array_map() by passing different callback function returning:
7 *   int, string, bool, null values
8 */
9
10echo "*** Testing array_map() : callback with diff return value ***\n";
11
12$array1 = array(1, 2, 3);
13$array2 = array(3, 4, 5);
14
15echo "-- with integer return value --\n";
16function callback_int($a, $b)
17{
18  return $a + $b;
19}
20var_dump( array_map('callback_int', $array1, $array2));
21
22echo "-- with string return value --\n";
23function callback_string($a, $b)
24{
25  return "$a"."$b";
26}
27var_dump( array_map('callback_string', $array1, $array2));
28
29echo "-- with bool return value --\n";
30function callback_bool($a, $b)
31{
32  return TRUE;
33}
34var_dump( array_map('callback_bool', $array1, $array2));
35
36echo "-- with null return value --\n";
37function callback_null($array1)
38{
39  return NULL;
40}
41var_dump( array_map('callback_null', $array1));
42
43echo "-- with no return value --\n";
44function callback_without_ret($arr1)
45{
46  echo "callback_without_ret called\n";
47}
48var_dump( array_map('callback_without_ret', $array1));
49
50echo "Done";
51?>
52--EXPECT--
53*** Testing array_map() : callback with diff return value ***
54-- with integer return value --
55array(3) {
56  [0]=>
57  int(4)
58  [1]=>
59  int(6)
60  [2]=>
61  int(8)
62}
63-- with string return value --
64array(3) {
65  [0]=>
66  string(2) "13"
67  [1]=>
68  string(2) "24"
69  [2]=>
70  string(2) "35"
71}
72-- with bool return value --
73array(3) {
74  [0]=>
75  bool(true)
76  [1]=>
77  bool(true)
78  [2]=>
79  bool(true)
80}
81-- with null return value --
82array(3) {
83  [0]=>
84  NULL
85  [1]=>
86  NULL
87  [2]=>
88  NULL
89}
90-- with no return value --
91callback_without_ret called
92callback_without_ret called
93callback_without_ret called
94array(3) {
95  [0]=>
96  NULL
97  [1]=>
98  NULL
99  [2]=>
100  NULL
101}
102Done
103