ID:               44022
 Updated by:       [EMAIL PROTECTED]
 Reported By:      martin at bang dot ca
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Linux
 PHP Version:      4.4.8
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

getTestArray() is called each time anew. Since in the first example
getTestArray() returns new array each time, it loops forever. 


Previous Comments:
------------------------------------------------------------------------

[2008-02-02 04:06:47] martin at bang dot ca

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'];
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44022&edit=1

Reply via email to