php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69723 Passing parameters by reference and array_column
Submitted: 2015-05-28 20:16 UTC Modified: -
From: j dot sarachaga at case-inc dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: master-Git-2015-05-28 (Git) OS: Linux\Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: j dot sarachaga at case-inc dot com
New email:
PHP Version: OS:

 

 [2015-05-28 20:16 UTC] j dot sarachaga at case-inc dot com
Description:
------------
I get an unexpected behavior when passing an array by reference and after that try to use the function array_column.

Test script:
---------------
<?php
function byReference( & $array){
    foreach($array as &$item){
        $item['nanana'] = 'batman';
        $item['superhero'] = 'robin';
    }
}

$array = [
    [
        'superhero'=> 'superman',
        'nanana' => 'no nana'
    ],
    [
        'superhero'=> 'acuaman',
        'nanana' => 'no nana'
    ],

];

var_dump(array_column($array, 'superhero'));
byReference($array);
var_dump(array_column($array, 'superhero'));


Expected result:
----------------
array(2) {
  [0]=>
  string(6) "batman"
  [1]=>
  string(6) "batman"
}


Actual result:
--------------
array(0) {
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-29 05:53 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ed8d1ba7dd3f37e60fbd9520ff35986d5c946812
Log: Fixed bug #69723 (Passing parameters by reference and array_column)
 [2015-05-29 05:53 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:38 UTC] davey@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ed8d1ba7dd3f37e60fbd9520ff35986d5c946812
Log: Fixed bug #69723 (Passing parameters by reference and array_column)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC