title: How to search an array key by matching a string in it's value
body: <p>I'm trying to find the key number in a array matching a string.</p>
  
  <p>I tried array_search in this way</p>
  
  <pre><code>$key = array_search("foo", $array);
  echo $array[$key];
  </code></pre>
  
  <p>but that prints $array[0]</p>
  
  <p>Is there another way to do this?</p>
  
  <p>Thanks :)</p>