Doc #80699 [Opn->Csd]: array_map no longer passes by reference
Edit report at https://bugs.php.net/bug.php?id=80699&edit=1
ID: 80699
Updated by: git@php.net
Reported by: donatj at gmail dot com
Summary: array_map no longer passes by reference
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Scripting Engine problem
Operating System: All
PHP Version: 8.0.1
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/31cacb6f262f455c616094cfe6d09bc0d1df2748
Log: Fix #80699: array_map no longer passes by reference
Previous Comments:
------------------------------------------------------------------------
[2021-02-02 19:45:26] bwoebi@php.net
Yes, that's an intentional change; if you need a reference, there is array_walk for that.
------------------------------------------------------------------------
[2021-02-02 19:24:50] donatj at gmail dot com
Description:
------------
array_map no longer passes by-reference.
This has broken a lot of things for us.
This very well may be an intentional change, but I didn't see it noted, and if it is, it should
be documented on the array_map page as a change?
Test script:
---------------
<?php
// https://3v4l.org/BdWq7
$data = array(
array(1,2,3),
array(4,5,6),
);
$data = array_map('reset', $data);
print_r($data);
Expected result:
----------------
Array
(
[0] => 1
[1] => 4
)
Actual result:
--------------
Warning: reset(): Argument #1 ($array) must be passed by reference, value given in /in/BdWq7 on line
8
Warning: reset(): Argument #1 ($array) must be passed by reference, value given in /in/BdWq7 on line
8
Array
(
[0] => 1
[1] => 4
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80699&edit=1
Thread (2 messages)