php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23666 array_pop() does not reset
Submitted: 2003-05-16 16:54 UTC Modified: 2003-05-16 18:37 UTC
From: goodie at apollointeractive dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.1 OS: All
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: goodie at apollointeractive dot com
New email:
PHP Version: OS:

 

 [2003-05-16 16:54 UTC] goodie at apollointeractive dot com
As stated in bug 21998 the functionality of array_pop has changed.  It used to reset the array pointer, but stopped doing so in version 4.3.0.  This behavior is still present in 4.3.1, causing anyone upgrading from an older PHP version to have to add calls to reset() in code that makes calls to array_pop().  As a result of bug 21998 the documentation was updated to state that array_pop() resets the pointer, but it appears that the source code was not altered to make this happen.  The functionality should be changed to reset the pointer so that it is consistent with both the documentation and previous versions of PHP.  This could be present in other functions that operate on arrays, such as array_shift().  

Example
<?php
$states = array ("CA"=> "California",
"NV" => "Nevada",
"NM" => "New Mexico");
array_pop($states);
while (list($key,$val) = each($states)){
echo "$key = $val\n";
}
?>
expected output is:
CA = California
NV = Nevada

Actual output is blank, due to pointer not being reset.  

We are running a debug build of 4.3.2 on FreeBSD.
'./configure' '--with-mssql=/www/lib/freetds-0.61' '--with-mysql=/www/mysql' '--with-apache=../apache_1.3.27.php.debug' '--enable-track-vars' '--enable-calendar' '--enable-ftp' '--enable-trans-sid' '--prefix=/www' '--with-zlib' '--enable-debug' 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-16 16:56 UTC] goodie at apollointeractive dot com
I incorrectly stated that we are using version 4.3.2, we are using 4.3.1
 [2003-05-16 18:37 UTC] magnus@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

If you would read the NEWS file you would see that no 
other fixes except the security fix was added in 4.3.1.. 
This fix will be in 4.3.2. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 18:01:28 2024 UTC