#35444 [Opn->Bgs]: Functions next/prev don't change array pointer on global array in function

From: Date: Mon, 28 Nov 2005 12:17:49 +0000
Subject: #35444 [Opn->Bgs]: Functions next/prev don't change array pointer on global array in function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-89202@lists.php.net to get a copy of this message
ID: 35444 Updated by: tony2001@php.net Reported By: gentoo at slave dot umbr dot cas dot cz -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux Gentoo and Fedora Core 2 PHP Version: 4.4.1 New Comment: Fixed in CVS about a month ago. Previous Comments: ------------------------------------------------------------------------ [2005-11-28 13:16:58] gentoo at slave dot umbr dot cas dot cz Description: ------------ If you have user defined function and this function uses global array (using global $ARRAY;), you cannot use functions next()/prev(), because they do not change internal array pointer. Reproduce code: --------------- $msort=array(); function do_print_test() { global $msort; reset($msort);echo sprintf("0:%s=%s\n",key($msort),current($msort)); next($msort);echo sprintf("1:%s=%s\n",key($msort),current($msort)); next($msort);echo sprintf("2:%s=%s\n",key($msort),current($msort)); next($msort);echo sprintf("3:%s=%s\n",key($msort),current($msort)); next($msort);echo sprintf("4:%s=%s\n",key($msort),current($msort)); } array_push($msort,"a"); array_push($msort,"b"); array_push($msort,"c"); array_push($msort,"d"); array_push($msort,"e"); array_push($msort,"f"); do_print_test(); Expected result: ---------------- in PHP 4.3.9 and 4.4.0 0:0=a 1:1=b 2:2=c 3:3=d 4:4=e Actual result: -------------- in PHP 4.4.1 0:0=a 1:0=a 2:0=a 3:0=a 4:0=a ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35444&edit=1

« previous php.bugs (#89202) next »