php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25699 for does not execute from within foreach
Submitted: 2003-09-30 02:18 UTC Modified: 2003-09-30 02:44 UTC
From: richy at smilingsouls dot net Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: 4.3.3 OS: Windows XP Home
Private report: No CVE-ID: None
 [2003-09-30 02:18 UTC] richy at smilingsouls dot net
Description:
------------
I have tried several variations of trying to use a for loop from within a foreach.  In no case did the for loop execute.

I have no idea if this is simply not allowed, or a bug.  But it has frustrated me enough to report it!

This works neither on my home dev. server (Xitami, Windows XP, PHP 4.3.3 R4) or on my remote ISP which sports some flavor of Unix.  See server config at http://www.smilingsouls.net/phpinfo.php



Reproduce code:
---------------
function foo()
{
	$foo[1] = 'test1';
	$foo[2] = 'test2';	
			
	foreach($foo as $key => $value)
	{
	
		for($d = 0; $d == 10; $d++) {echo $d;}
					
	}
			
}

function foo2()
{
	$foo[1] = 'test1';
	$foo[2] = 'test2';	
			
	foreach($foo as $key => $value)
	{
	
		loop_it();
					
	}
			
}
		
function loop_it()
{
	for($d = 0; $d == 10; $d++) {echo $d;}			
}
		
$foo[1] = 'test1';
$foo[2] = 'test2';
			
foreach($foo as $key => $value)
{
			
	loop_it();
					
}

Expected result:
----------------
each should output:
012345678910
012345678910



Actual result:
--------------
blank, nothing!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-30 02:35 UTC] richy at smilingsouls dot net
I figured out that the condition wasn't ever being met.
 [2003-09-30 02:44 UTC] alan_k@php.net
Bogusing..
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 29 08:01:25 2020 UTC