|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-05-25 18:40 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2017-05-25 18:40 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 08 07:00:02 2025 UTC |
Description: ------------ In php 5.5, using the ?: operator in reference based foreach loops worked. In php 7.1 the reference doesn't affect the original array any more. Test script: --------------- <?php $a=['hello' => [1,2,3]]; foreach ($a['hello'] ?: [] as &$x) $x++; print_r($a); Expected result: ---------------- In PHP 5.5 and PHP 5.6 the output is: Array ( [hello] => Array ( [0] => 2 [1] => 3 [2] => 4 ) ) Actual result: -------------- In PHP 7.1 the output is: Array ( [hello] => Array ( [0] => 1 [1] => 2 [2] => 3 ) )