title: Checking if value exists in array with array_search()
body: <p>If <code>0</code> could be a possible key returned from <code>array_search()</code>, what would be the best method for testing if an element exists in an array using this function (or any php function; if there's a better one, please share)?  </p>
  
  <p>I was trying to do this:</p>
  
  <pre><code>if(array_search($needle, $haystack)) //...
  </code></pre>
  
  <p>But that would of course return <code>false</code> if <code>$needle</code> is the first element in the array. I guess what I'm asking is is there some trick I can do in this <code>if</code> statement to get it to behave like I want it? I tried doing these, but none of them worked:</p>
  
  <pre><code>$arr = array(3,4,5,6,7);
  
  if(array_search(3, $arr) != false)  //...
  
  if(array_search(3, $arr) &gt;= 0)  //...
  </code></pre>
  
  <p>Appreciate the help.</p>