PHP 4.0 Bug #6436: foreach doesn't work right in recursive functions
| From: | kosy_denis at yahoo dot com | Date: | Wed, 30 Aug 2000 12:44:17 +0000 |
| Subject: | PHP 4.0 Bug #6436: foreach doesn't work right in recursive functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-31237@lists.php.net to get a copy of this message | ||
From: kosy_denis@yahoo.com
Operating system: win98 Second Edition
PHP version: 4.0.2
PHP Bug Type: Scripting Engine problem
Bug description: foreach doesn't work right in recursive functions
<?php
$ar = array(1,2,3,4,5,6,7,8);
$q = count($ar);
function test()
{
echo "<br>in";
static $max = 0;
static $exit_flag = FALSE;
if ( $max < 4 )
{
++$max;
}
else
{
$exit_flag = TRUE;
}
if ($exit_flag)
{
return;
}
global $ar, $q;
$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();
?>