xref: /PHP-7.3/ext/standard/tests/array/bug40709.phpt (revision 782352c5)
1--TEST--
2Bug #40709 (array_reduce() behaves strange with one item stored arrays)
3--FILE--
4<?php
5function CommaSeparatedList($a, $b) {
6    if($a == null)
7        return $b;
8    else
9        return $a.','.$b;
10}
11
12$arr1 = array(1,2,3);
13$arr2 = array(1);
14
15echo "result for arr1: ".array_reduce($arr1,'CommaSeparatedList')."\n";
16echo "result for arr2: ".array_reduce($arr2,'CommaSeparatedList')."\n";
17echo "result for arr1: ".array_reduce($arr1,'CommaSeparatedList')."\n";
18echo "result for arr2: ".array_reduce($arr2,'CommaSeparatedList')."\n";
19
20echo "Done\n";
21?>
22--EXPECT--
23result for arr1: 1,2,3
24result for arr2: 1
25result for arr1: 1,2,3
26result for arr2: 1
27Done
28