title: Stop script when item occurs in array
body: <p>I've got an array like this</p>
  
  <pre><code>array
    2 =&gt; string 'Member forum 1'
    5 =&gt; string 'Member forum 5'
    8 =&gt; string 'Moderator forum 8'
    9 =&gt; string 'Member forum 9'
  </code></pre>
  
  <p>I would like to write a script that, once it hits the <code>Moderator</code>-tag, stops looking for the tag and continue with a variable which contains <code>true</code> or something alike for which I can tell a user is a Moderator on any form of just a normal member.</p>
  
  <p>I have been experimenting with <code>in_array</code> and <code>preg_match</code> but everytime I end up with a <code>false</code> result, cause the last item of the array (<code>Member forum 9</code>) overwrites the  <code>true</code> value of the last but one value (<code>Moderator forum 8</code>).</p>
  
  <p>Here is my try. <code>$user_roles</code> being the array mentionned above.</p>
  
  <pre><code>$user_roles = $user-&gt;roles;
  
  foreach($user_roles as $value) {
      if(preg_match('Moderator', $value)) {
          var_dump('yep, moderator');
          break;
      } elseif(preg_match('Redacteur', $value)) {
          var_dump('jep, redacteur');
          break;
      } else {
          var_dump('nope');
      }
  }
  </code></pre>