title: PHP break, continue in 2 loop
body: <p>I'm a little confused about breaking out and continuing out of loops etc. I have 2 SQL queries that match user priveleges against the user's actual priveleges with the new ones put it. However, if some of the new priveleges match the one the user has, I want to skip the SQL insert and move on to the next one:</p>
  
  <pre><code>public static function insertPriveleges($user_id,$priveleges)
  {
      $ex = explode(",",$priveleges); // separated by commas
      if(count($ex)&gt;0)
      {
           $x = false;
           foreach($ex as $i =&gt; $priv)
           {
               $check_user = mysql_query("SELECT * FROM users_access_codes WHERE user_id='$user_id'") or die(mysql_error()); // get user's current priveleges
               while($check_data = mysql_fetch_array($check_user))
               {
                    if($check_data['access_code']!=$priv)
                    {
                        //if it doesn't match, insert 
                        $sql = "INSERT INTO users_access_codes (uaID,user_id,access_code) VALUES (NULL,'".$user_id."','$priv')";
                    }             
               }
           }
       }
  }
  </code></pre>
  
  <p>I almost never have a situation that needs to match more than two things in loops. I need to make sure I don't end up with double priveleges for that user. I know there must be a 'continue' statement somewhere in the inner loop, but not sure where.</p>