|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-06 20:59 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2021-07-06 20:59 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 05:00:01 2025 UTC |
Description: ------------ I'm using PHP 7.4.21 on Ubuntu 20.04 When you loop through an array the first time with pass by reference and then do it again without passing by reference, print_r will return unexpected values. The last item of the array will not be displayed, but the second to last. The array shouldn't be linked in any way to the pass be reference loop at the point. Test script: --------------- <?php $array = array('one', 'two', 'three', 'four'); foreach($array as &$value) { } foreach($array as $value) { } print_r($array); Expected result: ---------------- Array ( [0] => one [1] => two [2] => three [3] => four ) Actual result: -------------- Array ( [0] => one [1] => two [2] => three [3] => three )