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! } } Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/ 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... Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763019 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. Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763022 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; } Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763023 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 :-) Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763025 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; } Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763027 Share on other sites More sharing options...
eddy556 Posted February 15, 2009 Author Share Posted February 15, 2009 Thank you very much Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763029 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; } } Link to comment https://forums.phpfreaks.com/topic/145343-solved-breaking-out-of-two-statements-deep/#findComment-763036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.