PHP 4.0 Bug #6436 Updated: foreach doesn't work right in recursive functions
| From: | Bug Database | Date: | Wed, 30 Aug 2000 12:56:57 +0000 |
| Subject: | PHP 4.0 Bug #6436 Updated: foreach doesn't work right in recursive functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-31241@lists.php.net to get a copy of this message | ||
ID: 6436
Updated by: jmoore
Reported By: kosy_denis@yahoo.com
Status: Closed
Bug Type: Scripting Engine problem
Assigned To:
Comments:
<?php
$ar = array(1,2,3,4,5,6,7,8);
$q = count($ar);
function test()
{
global $ar, $q;
echo "<br>in";
static $max = 0;
$exit_flag = FALSE;
if ( $max < 4 )
{
++$max;
}
else
{
$exit_flag = TRUE;
}
if ($exit_flag == true)
{
return;
}
$i = 0;
foreach($ar as $a)
//for( $i = 0; $i < $q; ++$i )
{
++$i;
echo "<br> $max - $exit_flag - $i";
if ( $i == ( $q / 2 ) )
{
test();
}
}
echo "<br>---------------";
}
test();
?>
Works..
Full Bug description available at: http://bugs.php.net/?id=6436