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";
32try {
33	var_dump( array_map(b"callback2", $arr1) );
34} catch (Throwable $e) {
35	echo "Exception: " . $e->getMessage() . "\n";
36}
37
38echo "Done";
39?>
40--EXPECT--
41*** Testing array_map() : array with binary data for 'arr1' argument ***
42-- checking binary safe array with one parameter callback function --
43array(4) {
44  [0]=>
45  string(5) "hello"
46  [1]=>
47  string(5) "world"
48  [2]=>
49  string(1) "1"
50  [3]=>
51  string(5) "22.22"
52}
53-- checking binary safe array with two parameter callback function --
54Exception: Too few arguments to function callback2(), 1 passed and exactly 2 expected
55Done
56