I am attempting to assign the string returned by the fgets() function to an array in PHP. I have tried test strings and they work fine. I have also made sure that fgets() is returning items, but still no joy. Thinking that it may be a timing issue, I had the function run onload and that didn't work. My code is below; any help on this would be much appreciated.
function createDataArray()
{
global $resultsArray;
$i = 0;
$file = fopen("downloads/E0.csv","r");
while(! feof($file))
{
$line = fgets($file, 4096);
$resultsArray[$i] = $line; //This isn't working. Something is wrong with $line. It is a string, but it doesn't get assigned to the array.
$i = $i + 1;
}
fclose($file);
}