php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43890 function changes the internal pointer of its array parameter
Submitted: 2008-01-18 20:47 UTC Modified: 2008-02-02 01:00 UTC
From: jwang at navarik dot com Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 5.2.5 OS:
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
28 - 25 = ?
Subscribe to this entry?

 
 [2008-01-18 20:47 UTC] jwang at navarik dot com
Description:
------------
The function which is supposed to get a copy of the original array and never mess the original array magically changed the internal pointer of the original array. Noticed it doesn't change the pointer if foreach just loop though the array itself (this seems to be fixed in #40705). However, as it is in the repro code, I loop though a subelement of the array, it still changes the pointer.


Reproduce code:
---------------
<?php

function a($arr)

{

        foreach($arr['k'] as $r)

        {

        }

}

 

$arr = array(

        'k' => array(1)

);

a($arr);

var_dump(current($arr['k']));

Expected result:
----------------
int(1)


Actual result:
--------------
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 20:01:29 2024 UTC