title: PHP array_search consistently returns first key of array
body: <p>I recently noticed trouble when using the array_search function in my code. I am searching the array "$allcraftatts" for the value "sharp". I tried to isolate the problem by setting up a two line experiment:</p>
  
  <pre><code>$testcopy=$allcraftatts;
  $testsharp=array_search("sharp", $testcopy);
  </code></pre>
  
  <p>Using "print_r(get_defined_vars());" later on, I get this result:</p>
  
  <pre><code>[testcopy] =&gt; Array
                  (
                      [0] =&gt; 0
                      [1] =&gt; 0
                      [2] =&gt; 0
                      [3] =&gt; 0
                      [4] =&gt; 0
                      [5] =&gt; 0
                      [6] =&gt; Sharp Stone
                      [7] =&gt; Sharp Stones
                      [8] =&gt; stone
                      [9] =&gt; object
                      [10] =&gt; sharp
                      [11] =&gt; hard
                      [12] =&gt; 0
                      [13] =&gt; 0
                      [14] =&gt; 0
                      [15] =&gt; 0
                      [16] =&gt; 0
                      [17] =&gt; 0
                      [18] =&gt; 0
                  )
  
  [testsharp] =&gt; 0
  </code></pre>
  
  <p>I made sure that I do not modify these variables at any other time.</p>
  
  <p>Now, if I change my code to</p>
  
  <pre><code>$testcopy=$allcraftatts;
  unset($testcopy[0]);
  $testsharp=array_search("sharp", $testcopy);
  </code></pre>
  
  <p>it returns "1".</p>
  
  <p>This leads me to believe that it always returns the first key in the array.</p>
  
  <p>It baffles me! This is one of those bugs that makes you fear something wrong with the language itself. However doubtful this is, I actually was eventually driven to looking at the PHP source for something wrong there, but unfortunately could not understand it.</p>
  
  <p>Seeing that it is a function simple as this, I will most definitely be completely humiliated by the inevitably simple answer, but at this point, I just want an answer.</p>