Jump to content

Moving on to the next FOREACH via IF statement inside FUNCTION?


Dismal_Bliss

Recommended Posts

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

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.