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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 29 06:01:29 2024 UTC