|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-08 23:22 UTC] stas@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Mar 13 05:00:01 2026 UTC |
Description: ------------ Infinite loop when using a function call which returns an array in each( ) Reproduce code: --------------- Infinite loop here (prints "1 -> 1\n" forever) while( list( $k, $v ) = each( getTestArray() ) ) { echo "$k -> $v\n"; } function getTestArray() { return array( "1" => "1" ); } This works OK (prints "1 -> 1" once): $GLOBALS['test'] = array( "1" => "1" ); while( list( $k, $v ) = each( getTestArray() ) ) { echo "$k -> $v\n"; } function getTestArray() { return $GLOBALS['test']; }