#35444 [NEW]: Functions next/prev don't change array pointer on global array in function
| From: | gentoo at slave dot umbr dot cas dot cz | Date: | Mon, 28 Nov 2005 12:16:59 +0000 |
| Subject: | #35444 [NEW]: Functions next/prev don't change array pointer on global array in function | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-89201@lists.php.net to get a copy of this message | ||
From: gentoo at slave dot umbr dot cas dot cz
Operating system: Linux Gentoo and Fedora Core 2
PHP version: 4.4.1
PHP Bug Type: Arrays related
Bug description: Functions next/prev don't change array pointer on global array in function
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 bug report at http://bugs.php.net/?id=35444&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35444&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35444&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35444&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=35444&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35444&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35444&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35444&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35444&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35444&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35444&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35444&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35444&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35444&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35444&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35444&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35444&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35444&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35444&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35444&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35444&r=mysqlcfg