title: How does PHP's in_array function work?
body: <p>I am not a computer scientist or have strong algorithmic knowledge, but today I began to wonder how does PHP's <a href="http://php.net/manual/en/function.in-array.php" rel="nofollow">in_array</a> method work under the hood. It seems pretty straight-forward, loop through all the array's elements and check the current element against a given value. But even with larger arrays it still works very quickly. How?</p>
  
  <pre><code>&lt;?php
  $distros = ["Mint", "Debian", "Ubuntu", "Fedora", "CentOS", "Arch"];
  if (in_array("Ubuntu", $distros)) {
      echo "Got Ubuntu";
  }
  </code></pre>