I have a file arranged like so:
"url1","info1"
"url2","info2"
"url3","info3" ... all the way up to "url15","info15"
I would like to read the last 10 lines of the file into an array such that $pagelist[0][0] would give url5 and $pagelist[0][1] would give info5.
My current code is as follows:
$file=fopen(csvfile.txt,"r");
$pagelist=array();
$i=0;
$key=0;
while (!feof($file)) {
if ($i >= (count($file)-11)) {
$pagelist[$key]=fgetcsv($file);
$key++; }
$i++;
}
fclose($file)
When I used print_r($pagelist) it seemed to have loaded all the lines of the file into the array instead of just the last 10. Can anyone see what I've done wrong in my code? thanks :)