#43890 [Opn->Fbk]: function changes the internal pointer of its array parameter

From: Date: Sat, 26 Jan 2008 00:57:23 +0000
Subject: #43890 [Opn->Fbk]: function changes the internal pointer of its array parameter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121554@lists.php.net to get a copy of this message
ID: 43890 Updated by: jani@php.net Reported By: jwang at navarik dot com -Status: Open +Status: Feedback Bug Type: Arrays related PHP Version: 5.2.5 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.3-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.3-win32-installer-latest.msi Previous Comments: ------------------------------------------------------------------------ [2008-01-18 20:47:00] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43890&edit=1

« previous php.bugs (#121554) next »