title: Where does the PHP file() function get line numbers?
body: <p>When I execute the following code, I get output a list of lines from the file, with line numbers.</p>
  
  <pre><code>&lt;?php
  $lines = file('C:\sm\lines.txt');
  foreach ($lines as $line_num =&gt; $line) {
      echo "Line #&lt;b&gt;{$line_num}&lt;/b&gt; : " . htmlspecialchars($line) . "&lt;br /&gt;\n";
  }
  ?&gt;
  </code></pre>
  
  <p>Now I would imagine the array returned by <code>file()</code> would be a simple one dimensional vector, and I would have to keep a line_num variable in my loop. How do things work here that I get the associative pair <code>$line_num =&gt; $line</code> for each line in the file?</p>