Bug #71660 [NEW]: array_column behaves incorrectly after foreach by reference
| From: | icarpenter at leadid dot com | Date: | Thu, 25 Feb 2016 00:12:39 +0000 |
| Subject: | Bug #71660 [NEW]: array_column behaves incorrectly after foreach by reference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-199468@lists.php.net to get a copy of this message | ||
From: icarpenter at leadid dot com
Operating system:
PHP version: 7.0.3
Package: Arrays related
Bug Type: Bug
Bug description:array_column behaves incorrectly after foreach by reference
Description:
------------
If you do a foreach by reference on an array, array_column will ignore
the third parameter
Test script:
---------------
<?php
$arr = array('id' => 12345, 'name' => 'sam');
foreach ($arr as &$v) {
$v = $v;
}
$arr = [$arr];
var_dump(array_column($arr, 'name', 'id'));
Expected result:
----------------
array(1) {
[12345]=>
string(3) "sam"
}
Actual result:
--------------
array(1) {
[0]=>
&string(3) "sam"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=71660&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71660&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71660&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71660&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71660&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71660&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71660&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71660&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71660&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71660&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71660&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71660&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71660&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71660&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71660&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71660&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71660&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71660&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71660&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71660&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71660&r=mysqlcfg