Bug #74077 [NEW]: Array_map with null argument inconsistency
From: remyfox at hotmail dot com
Operating system: Windows 10
PHP version: 7.1.1
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Array_map with null argument inconsistency
Description:
------------
In the array map documentation
(http://php.net/manual/en/function.array-map.php) under #4 there is an
example of using null as argument so as to make an array of arrays. This
works fine for as long one item is provided to the array_map function.
However, if there are is just one item provided, then the function will
fail to be consistent.
Test script:
---------------
$two_item_array = [["abc", "def"], ["ghi", "jkl"]];
$one_item_array = [["abc", "def"]];
print_r(array_map(null, ...$two_item_array));
print_r(array_map(null, ...$one_item_array));
Expected result:
----------------
Array
(
[0] => Array
(
[0] => abc
[1] => ghi
)
[1] => Array
(
[0] => def
[1] => jkl
)
)
Array
(
[0] => Array
(
[0] => abc
)
[1] => Array
(
[0] => def
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => abc
[1] => ghi
)
[1] => Array
(
[0] => def
[1] => jkl
)
)
Array
(
[0] => abc
[1] => def
)
--
Edit bug report at https://bugs.php.net/bug.php?id=74077&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74077&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74077&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74077&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74077&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74077&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74077&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74077&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74077&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74077&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74077&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74077&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74077&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74077&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74077&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74077&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74077&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74077&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74077&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74077&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74077&r=mysqlcfg
Thread (5 messages)
- remyfox at hotmail dot com