Jump to content

[SOLVED] Breaking out of two statements deep


eddy556

Recommended Posts

Please see the following code - I need to break out of the code if the if statement fires, I've tried break but it doesn't seem to do anything.

 

foreach($_POST as $var => $value)
			{

						echo "Array title: " . $Movies[$movieno]["title"] . "<br />";
						echo "Post value: " . str_replace('_', ' ', $var) . "<br />";



				if($Movies[$movieno]["title"] = str_replace('_', ' ', $var))						
					{	

						$Movies[$movieno]["rating"] = $value;
						//need to break outta here!



					}


			}

Yea sorry it was in there (promise lol) I've just replaced it with the comment.

 

Dude, I still don't see any break in there, but anyways here you go:

 

 

    if($Movies[$movieno]["title"] = str_replace('_', ' ', $var))                 

                  { 

                   

                    $Movies[$movieno]["rating"] = $value;

                    break;

                   

                 

                   

                  }

I see...

 

 

foreach($_POST as $var => $value)
            {
                  
                     echo "Array title: " . $Movies[$movieno]["title"] . "<br />";
                     echo "Post value: " . str_replace('_', ' ', $var) . "<br />";
                     
                     
                     
               if($Movies[$movieno]["title"] = str_replace('_', ' ', $var))                  
                  {   
                     
                     $Movies[$movieno]["rating"] = $value;
                     $i_am_breaking = "true";
                     break;

                  }
           if($i_am_breaking == "true") break;
}

foreach($_POST as $var => $value) {
    echo "Array title: " . $Movies[$movieno]["title"] . "<br />";
    echo "Post value: " . str_replace('_', ' ', $var) . "<br />";
    if ($Movies[$movieno]["title"] = str_replace('_', ' ', $var)) {   
        $Movies[$movieno]["rating"] = $value;
        $i_am_breaking = "true";
       break 2;
    }
}

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.