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

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;

}

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

 

 

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.