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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 - 10 = ?
Subscribe to this entry?

 
 [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: Sun May 05 18:01:31 2024 UTC