title: In PHP, 0 (int, zero) is equal to "first" or "last" (strings)?
body: <p>I'm confused by something I just ran into in a script I was working on.  I had the following:</p>
  
  <pre><code>function getPart($part)
  {
      $array = array('a', 'b', 'c');
      if ($part == 'first') $part = 0;
      if ($part == 'last') $part = count($array) - 1;
      if (isset($array[$part])) return $array[$part];
      return false;
  }
  
  $position = 0;
  echo getPart($position);
  </code></pre>
  
  <p>So, if I were to try the string "first", I should get "a" as the output.  With the string "last" I should get "c" and so on.  When I run the script above, with PHP 5.3, I get "c" ...</p>
  
  <p>Confused, I ran a quick test ...</p>
  
  <pre><code>var_dump(0 == 'first');
  var_dump(0 == 'last');
  </code></pre>
  
  <p>Both return <code>TRUE</code> ... <strong>WHY???</strong>  I am so confused by this behavior!</p>