1--TEST--
2Test array_map() function : usage variations - binary safe checking
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 array having binary values for $arr1 argument
12 */
13
14echo "*** Testing array_map() : array with binary data for 'arr1' argument ***\n";
15
16function callback1($a)
17{
18  return ($a);
19}
20function callback2($a, $b)
21{
22  return array($a => $b);
23}
24
25// array with binary data
26$arr1 = array(b"hello", b"world", "1", b"22.22");
27
28echo "-- checking binary safe array with one parameter callback function --\n";
29var_dump( array_map('callback1', $arr1) );
30
31echo "-- checking binary safe array with two parameter callback function --\n";
32var_dump( array_map(b"callback2", $arr1) );
33
34echo "Done";
35?>
36--EXPECTF--
37*** Testing array_map() : array with binary data for 'arr1' argument ***
38-- checking binary safe array with one parameter callback function --
39array(4) {
40  [0]=>
41  string(5) "hello"
42  [1]=>
43  string(5) "world"
44  [2]=>
45  string(1) "1"
46  [3]=>
47  string(5) "22.22"
48}
49-- checking binary safe array with two parameter callback function --
50
51Warning: Missing argument 2 for callback2() in %s on line %d%d
52
53Notice: Undefined variable: b in %s on line %d%d
54
55Warning: Missing argument 2 for callback2() in %s on line %d%d
56
57Notice: Undefined variable: b in %s on line %d%d
58
59Warning: Missing argument 2 for callback2() in %s on line %d%d
60
61Notice: Undefined variable: b in %s on line %d%d
62
63Warning: Missing argument 2 for callback2() in %s on line %d%d
64
65Notice: Undefined variable: b in %s on line %d%d
66array(4) {
67  [0]=>
68  array(1) {
69    ["hello"]=>
70    NULL
71  }
72  [1]=>
73  array(1) {
74    ["world"]=>
75    NULL
76  }
77  [2]=>
78  array(1) {
79    [1]=>
80    NULL
81  }
82  [3]=>
83  array(1) {
84    ["22.22"]=>
85    NULL
86  }
87}
88Done
89