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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC