Dismal_Bliss Posted May 29, 2010 Share Posted May 29, 2010 Hello, I am hacking a script and have hit a little snag. I could greatly add to the script to make this work, but it would be easier if I could simply make this happen the way I want it. foreach ( $mails as $mail ) { process_individual_mail_to_post ( $mail, $forum_id ); } and then later.... function process_individual_mail_to_post ( $mail, $forum_id ) { some stuff, then.... if ($use_email_for_login) { $new_message["user_id"] = forum_api_user_search ( "email", $new_message ["email"] ); if(!empty($new_message["user_id"])) { $user = forum_api_user_get ( $new_message ["user_id"], false ); $new_message ["author"] = $user ["display_name"]; $new_message ["email"] = ""; $GLOBALS ["BBBOARD"] ["user"] ["user_id"] = $new_message ["user_id"]; } else { SOMETHING RIGHT HERE TO IGNORE EVERYTHING THAT FOLLOWS AND MOVE ONTO THE NEXT EMAIL IN MY "FOREACH" LOOP } It has to be something simple. Thanks! - Bob Quote Link to comment https://forums.phpfreaks.com/topic/203292-moving-on-to-the-next-foreach-via-if-statement-inside-function/ Share on other sites More sharing options...
jcbones Posted May 29, 2010 Share Posted May 29, 2010 SOMETHING RIGHT HERE TO IGNORE EVERYTHING THAT FOLLOWS AND MOVE ONTO THE NEXT EMAIL IN MY "FOREACH" LOOP = return; Quote Link to comment https://forums.phpfreaks.com/topic/203292-moving-on-to-the-next-foreach-via-if-statement-inside-function/#findComment-1065101 Share on other sites More sharing options...
kenrbnsn Posted May 29, 2010 Share Posted May 29, 2010 Just return from the function. <?php else { return (); } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/203292-moving-on-to-the-next-foreach-via-if-statement-inside-function/#findComment-1065103 Share on other sites More sharing options...
ignace Posted May 29, 2010 Share Posted May 29, 2010 Or alternatively: define('LOOP_CONTINUE', 1); define('LOOP_BREAK', 2); function blaBlaBla($bla) { if ($bla) { return LOOP_CONTINUE; } else { return LOOP_BREAK; } } In your loop: foreach ($mails as $mail) { $return = blaBlaBla($mail); if (LOOP_CONTINUE === $return) continue; if (LOOP_BREAK === $return) break; } Quote Link to comment https://forums.phpfreaks.com/topic/203292-moving-on-to-the-next-foreach-via-if-statement-inside-function/#findComment-1065112 Share on other sites More sharing options...
Dismal_Bliss Posted May 30, 2010 Author Share Posted May 30, 2010 Thanks for all the input. The return(); did not work. So what I did was in the "else" section I added $non_member="true" and then put the remaining code in an IF statement as well. If the non_member was empty, all that code got executed. If ELSE it was "true", then the code got skipped and an email was sent to the sender telling them their message was denied. Now onto my next problem, found here.... http://www.phpfreaks.com/forums/index.php/topic,299609.0.html - Bob Quote Link to comment https://forums.phpfreaks.com/topic/203292-moving-on-to-the-next-foreach-via-if-statement-inside-function/#findComment-1065238 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.