Jump to content

else in foreach problem


TehBotolSosro

Recommended Posts

hi all,

im still new with php, any my english are messed up so be patience :)

 

anyway i have a code like this

if ($Stop == "0")
{
    foreach ($bot->fobjects as $obj)
    {
if (($obj["className"] == "Home"))
        {
echo "Running";
		break;
	}
         else
            {
echo "Not Running";
                break;
            }
    }
}

 

the problem is, its not running the way it suppose to, as it always go to the else section even if there is an array with className Home inside the $bot->fobjects

and when i do the obj var_dump below the echo "Not Running"; it always show the wrong array

 

and the strange thing if i remove the else section, the code is working good and it show the correct array

 

is there something wrong with my code?

 

thank you

 

 

Link to comment
https://forums.phpfreaks.com/topic/230694-else-in-foreach-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.