Ok, first thing first, welcome to the board.
Now, to the business.
Starting from the end, your "include" solution don't work, because when you do an include, the content of the file included is imported into the web page.
It's not a returned from the include() function.
The return from the include() in your case is "TRUE", so nothing to split by line breaks.
fopen() is really the way to go.
What I see, is that it's a path related problem.
include() look into the default path to search for the file if it's not found at the current location (in the filesystem).
Fopen() does not try to find it. It looks just where you tell it to find the file.
Second, I'm not 100% sure, but I believe you must give it an absolute location. Ie, the fopen looks from the system file path root, not from the web site root point. But I don't see nothin in the docs about this. Maybe it's an old limitation that have been lifted.
Third, if you are on windows, according to php documentation, you must use the double backslashe notation to specify the file location.
http://www.php.net/manual/en/function.fopen.php
For all those reason, I recommend you to use an absolute path and to check for the file existence before trying to open it.
PHP Code:
$file = $_SERVER['DOCUMENT_ROOT'].'/jobs/jobs.txt';
if(!file_exists($file)){
die("file $file was not found");
}
if(!is_readable($file)){
die("file $file is not readable");
}
$fh=fopen($file,"r");
$prevLine="";
while(!feof($fh)){
$line=fgets($fh);
if($prevLine!=""){
echo '<a href="/jobs/'.$line.'">'.$prevLine.'</a><br />';
}
$prevLine=$line;
}
That way, you will test that the file exists, and that you can read it.
And rather than putting it into memory and then parsing the array (which is highly inneficient, and can led to php error if the file is too big) you read it line by line and echo the content without using more memory than 2 lines of the file.
By the way, this script imply that your server is running linux and that the jobs directory is located into the root directory of the site.
If you are on windows, replace "/jobs/jobs.txt" with "\\jobs\\jobs.txt" and adjust the path to your file location.