title: Get values from in_array statement
body: <p>I have an array filled with the result of a query which is as follows:</p>
  
  <pre><code>$ticket[] = array( 
      'ticket_id' =&gt; $row-&gt;ticket_id,
      'user_id' =&gt; $row-&gt;user_id,
      'raffle_ticket_num' =&gt; $row-&gt;raffle_ticket_num
  );
  </code></pre>
  
  <p>Now, in a while loop, I check in all arrays inside $tickets if my variable $number equals 'raffle_ticket_num'. I do this with the following code (from @Fuzzy Tree):</p>
  
  <pre><code>$ticket_num=1;
  
  while ($ticket_num &lt;= $total_slots){
  
      foreach($ticket as $test) {
          if($test['raffle_ticket_num'] == $ticket_num) { 
               echo $ticket_num.' claimed by '.$test['user_id'];
            }
  
          else{
               echo $ticket_num;
              }   
  
      }
  
  $ticket_num++;
  }
  </code></pre>
  
  <p>The problem that I'm having now is that because I'm using a foreach loop, if more than one results are found, it causes it to echo each result as much as there are rows in $ticket[]... So with 2 rows it echos everything 2 times (because of the foreach). Does anyone know a solution or alternatives for this? </p>
  
  <p>You can see it live here: <a href="http://tinyurl.com/hxbhx7y" rel="nofollow">http://tinyurl.com/hxbhx7y</a> .The bold numbers are slot 21 and 38 which are taken and showing the user_id (1). But as you can see it shows each number 2 times (because foreach has 2 results)</p>
  
  <p><strong>EDIT</strong>: Post updated with @Fuzzy Tree's answer</p>