#23666 [Opn]: array_pop() does not reset

From: Date: Fri, 16 May 2003 21:56:33 +0000
Subject: #23666 [Opn]: array_pop() does not reset
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39818@lists.php.net to get a copy of this message
ID: 23666 User updated by: goodie at apollointeractive dot com Reported By: goodie at apollointeractive dot com Status: Open Bug Type: Arrays related Operating System: All PHP Version: 4.3.1 New Comment: I incorrectly stated that we are using version 4.3.2, we are using 4.3.1 Previous Comments: ------------------------------------------------------------------------ [2003-05-16 16:54:44] 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' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23666&edit=1

« previous php.bugs (#39818) next »