eddy556 Posted February 15, 2009 Share Posted February 15, 2009 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! } } Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted February 15, 2009 Share Posted February 15, 2009 Umm, I don't see any "break" statement... Quote Link to comment Share on other sites More sharing options...
eddy556 Posted February 15, 2009 Author Share Posted February 15, 2009 Yea sorry it was in there (promise lol) I've just replaced it with the comment. Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted February 15, 2009 Share Posted February 15, 2009 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; } Quote Link to comment Share on other sites More sharing options...
eddy556 Posted February 15, 2009 Author Share Posted February 15, 2009 Yes I have done that - and just checked again... But I think the problem is I AM breaking out of the if(statement) however I ALSO need to break out of the foreach (only if that if statement was true). Hope you understand me :-) Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted February 15, 2009 Share Posted February 15, 2009 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; } Quote Link to comment Share on other sites More sharing options...
eddy556 Posted February 15, 2009 Author Share Posted February 15, 2009 Thank you very much Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted February 15, 2009 Share Posted February 15, 2009 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; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.