php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71644 foreach by value after foreach by reference repeats last element
Submitted: 2016-02-22 12:51 UTC Modified: 2016-02-22 19:07 UTC
From: bichinhoverde at spwinternet dot com dot br Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.6.18 OS: Linux
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: bichinhoverde at spwinternet dot com dot br
New email:
PHP Version: OS:

 

 [2016-02-22 12:51 UTC] bichinhoverde at spwinternet dot com dot br
Description:
------------
A foreach by value after a foreach by reference repeats the last element.

Test script:
---------------
$array[] = 'a';
$array[] = 'b';
$array[] = 'c';
$array[] = 'd';
$array[] = 'e';

foreach ( $array as &$element )
  echo $element;

foreach ( $array as $element )
  echo $element;


Expected result:
----------------
abcdeabcde

Actual result:
--------------
abcdeabcdd

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-22 19:07 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-02-22 19:07 UTC] requinix@php.net
See bug #71458
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 15:01:36 2025 UTC