PHP - Read text file and output contents as links won't work
<p>I have a text file in the same folder as the script I'm trying to run. It has several URL links each on a new line like so:</p>

<pre><code>hxxp://www.example.com/example1/a.doc
hxxp://www.example.com/example2/b.xls
hxxp://www.example.com/example3/c.ppt
</code></pre>

<p>I'm trying to link these files but it only lists the last file in the list.</p>

<p>Here is my code:</p>

<pre><code>&lt;?php

    $getLinks = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/links.txt');
    $files = explode("\n", $getLinks);

    foreach ($files as $file) {

        if (substr($file, 0, 23) == 'hxxp://www.example.com/') {
            $ext = pathinfo(strtolower($file));
            $linkFile = basename(rawurldecode($file));

            if ($ext['extension'] == 'doc') {
                echo '&lt;a href="' . $file . '"&gt;&lt;img src="images/word.png" /&gt;&amp;nbsp;' . $linkFile . '&lt;/a&gt;&lt;br /&gt;';
            } elseif ($ext['extension'] == 'xls') {
                echo '&lt;a href="' . $file . '"&gt;&lt;img src="images/excel.png" /&gt;&amp;nbsp;' . $linkFile . '&lt;/a&gt;&lt;br /&gt;';
            } elseif ($ext['extension'] == 'ppt') {
                echo '&lt;a href="' . $file . '"&gt;&lt;img src="images/powerpoint.png" /&gt;&amp;nbsp;' . $linkFile . '&lt;/a&gt;&lt;br /&gt;';
            }
        }
    }

?&gt;
</code></pre>

<p>*note: I've tried using the file function as well with the same results.</p>
