First, a disclaimer, I have no programming experience, I am just now learning. If that didn't scare you off, then I'll get on with my question.
The purpose of this snippet of code is to have a script that open a text file, read the contents, break each line into an array key, then display each key in a for loop.
Heres what I've written:
Code: Select all
$openlist = fopen("content/list.txt", 'r'); //opens the file
if (!$openlist)
{
echo '<strong>Whoopsie! Cant open list.txt!</strong>'; //no file!
exit;
}
$list = fgetcsv ($openlist, 100, "\n"); // supposed to break the list into array elements by line breaks
$num = count($list); // checking to see how many keys are made
echo ' how many keys there are in the $list array = '.$num.'<br>'."\n";
for ($i = 0; $i <= $num; $i++)
{
echo $listї$i].' this is key '.$i.'<br>'; // show me the keys
}
echo '<p> </p>';
fpassthru ($openlist); //making sure the list was opened
fclose ($openlist); //closing it
echo '<p> </p>';Code: Select all
03-12-30.txt
03-12-18.txt
03-12-12.txt
03-11-16.txt
03-11-02.txt
03-09.30.txtand finally, this is what is output:

I guess the problem is obvious. First of all the function of fgetcsv doesn't seem to recognize any lines past the first one and does not break them out to array keys (am I using the term "keys" correctly?).
Thanks in advance for any help you all can offer... I hope to be as good as you all someday.