title: PHP if in_array() how to get the key as well?
body: <p>Struggling with a tiny problem.</p>
  
  <p>I have an array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 
      [6] =&gt; 6
      [3] =&gt; 5
      [2] =&gt; 7
  )
  </code></pre>
  
  <p>I am checking if a set value is in the array.</p>
  
  <pre><code>if(in_array(5, $array)) {
  //do something
  } else {
  // do something else
  }
  </code></pre>
  
  <p>The thing is, when it find the value 5 in array, I really need the key to work with in my "do something".</p>
  
  <p>In this case I need to set:</p>
  
  <pre><code>$key = 3;
  </code></pre>
  
  <p>(key from the found value in_array).</p>
  
  <p>Any suggestions?</p>