1--TEST--
2Test array_pad() function : usage variations - binary safe checking
3--FILE--
4<?php
5/* Prototype  : array array_pad(array $input, int $pad_size, mixed $pad_value)
6 * Description: Returns a copy of input array padded with pad_value to size pad_size
7 * Source code: ext/standard/array.c
8*/
9
10/*
11* Passing binary values to $pad_value argument and testing whether
12* array_pad() behaves in an expected way with the other arguments passed to the function.
13* The $input and $pad_size arguments passed are fixed values.
14*/
15
16echo "*** Testing array_pad() : Passing binary values to \$pad_value argument ***\n";
17
18// initialize the $input and $pad_size argument
19$input = array(1, 2, 3);
20$pad_size = 6;
21
22// initialize $pad_value with reference variable
23$binary = b"hello";
24
25var_dump( array_pad($input, $pad_size, $binary) );  // positive 'pad_size'
26var_dump( array_pad($input, -$pad_size, $binary) );  // negative 'pad_size'
27
28echo "Done";
29?>
30--EXPECT--
31*** Testing array_pad() : Passing binary values to $pad_value argument ***
32array(6) {
33  [0]=>
34  int(1)
35  [1]=>
36  int(2)
37  [2]=>
38  int(3)
39  [3]=>
40  string(5) "hello"
41  [4]=>
42  string(5) "hello"
43  [5]=>
44  string(5) "hello"
45}
46array(6) {
47  [0]=>
48  string(5) "hello"
49  [1]=>
50  string(5) "hello"
51  [2]=>
52  string(5) "hello"
53  [3]=>
54  int(1)
55  [4]=>
56  int(2)
57  [5]=>
58  int(3)
59}
60Done
61