Reading lines from a file in PHP
<p>I'm having problems reading lines from a text file in PHP.</p>

<p>I have this code:</p>

<pre><code>$a_path = "./data/answers.txt";

    $answers = fopen($a_path);

    $line_num = 1;

    while ($line = fgets($answers))
    {
        for ($i = 0; $i &lt; count($common_q_line_nums); $i++)
        {
            if ($line_num == (int)$common_q_line_nums[$i])
            {
                echo $line;
            }
        }
        $line_num++;
    }
</code></pre>

<p>I am using Macintosh, however I updated the php.ini file with <code>auto_detect_line_endings = On</code></p>

<p>The <code>$common_q_line_nums</code> sorted array contains numbers in the range of the lines in the text file.</p>

<p>Any idea why I'm getting nothing back? The file is opening ok, and the <code>$common_q_line_nums</code> is good.</p>

<p>Appreciated, Alex</p>
