#23666 [NEW]: array_pop() does not reset
From: goodie at apollointeractive dot com
Operating system: All
PHP version: 4.3.1
PHP Bug Type: Arrays related
Bug description: array_pop() does not reset
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'
--
Edit bug report at http://bugs.php.net/?id=23666&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23666&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23666&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23666&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23666&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23666&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23666&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23666&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23666&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23666&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23666&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23666&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23666&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23666&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23666&r=gnused
Thread (3 messages)
- goodie at apollointeractive dot com