#39556 [Opn->Bgs]: Referenced Arrays with KEY and CURRENT

From: Date: Mon, 20 Nov 2006 09:24:25 +0000
Subject: #39556 [Opn->Bgs]: Referenced Arrays with KEY and CURRENT
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105194@lists.php.net to get a copy of this message
ID: 39556 Updated by: tony2001@php.net Reported By: randallgirard at hotmail dot com -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux? PHP Version: 4.4.4 New Comment: Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. Previous Comments: ------------------------------------------------------------------------ [2006-11-19 22:15:55] randallgirard at hotmail dot com Description: ------------ once an array is referenced elsewhere, it seems that KEY and CURRENT do not work as expected. I'm not sure of the version on the webhost I'm using, Reproduce code: --------------- $arr = array('0', '1', '2', '3'); reset($arr); print('Direct '); print('NEXT: '.next($arr).' '); print('NEXT: '.next($ref).' '); print('NEXT: '.next($ref).' '); print('KEY: '.key($arr).' '); print('CURRENT: '.current($arr).' '); print("<br><br>\n"); $ref =& $arr; reset($arr); print('Direct '); print('NEXT: '.next($arr).' '); print('NEXT: '.next($ref).' '); print('NEXT: '.next($ref).' '); print('KEY: '.key($arr).' '); print('CURRENT: '.current($arr).' '); print("<br><br>\n"); reset($ref); print('Referended '); print('NEXT: '.next($ref).' '); print('NEXT: '.next($ref).' '); print('NEXT: '.next($ref).' '); print('KEY: '.key($ref).' '); print('CURRENT: '.current($ref).' '); print("<br><br>\n"); Expected result: ---------------- Direct NEXT: 1 NEXT: 2 NEXT: 3 KEY: 3 CURRENT: 3 Direct NEXT: 1 NEXT: 2 NEXT: 3 KEY: 3 CURRENT: 3 Referended NEXT: 1 NEXT: 2 NEXT: 3 KEY: 3 CURRENT: 3 Actual result: -------------- Direct NEXT: 1 NEXT: 2 NEXT: 3 KEY: 3 CURRENT: 3 Direct NEXT: 1 NEXT: 2 NEXT: 3 KEY: 0 CURRENT: 0 Referended NEXT: 1 NEXT: 2 NEXT: 3 KEY: 0 CURRENT: 0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39556&edit=1

« previous php.bugs (#105194) next »