title: Search array by values and return keys
body: <p>I have values passed <em>c</em> and <em>3</em> from <code>$_GET</code> variable, which I want to look up in an array as values and retrieve their keys. How can I search through the array to return accurate keys?</p>
  
  <p>The code below</p>
  
  <pre><code>&lt;?php
  
  $array1 = array(0 =&gt; 'a', 1 =&gt; 'c', 2 =&gt; 'c');
  $array2 = array(0 =&gt; '3', 1 =&gt; '2', 2 =&gt; '3');
  
  $key1 = array_search('c', $array1);
  $key2 = array_search('3', $array2);
  
  ?&gt;
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>$key1 = 1;
  $key2 = 0;
  </code></pre>
  
  <p>though I am expecting</p>
  
  <pre><code>$key1 = 2;
  $key2 = 2;
  </code></pre>