I'm tring to read in the text file found here: http://www1.m2.mediacat.ne.jp/binews/use/bia13.txt
It's a tab delimited list of shortwave radio broadcast schedules that I want to stuff into a MySQL database. I'm able to download it and get it into an array. A var_dump shows it's all there. However...
$schedule=file('schedule.txt');
foreach($schedule as $line)
{
echo $line.'<br>';
}
Only shows the last line of the file.
for ($i; $i<=count($schedule);$i++)
{
echo $schedule[$i];
}
generates an Apache 500 internal server error (premature end of script headers).
but, if I do this:
echo $schedule[0];
It properly displays that line.
So, I'm assuming somewhere in the array are some unprintable or control characters that are giving Apache fits.
I have done:
$bigstring=json_encode($schedule);
$schedule=$json_decode($bigstring);
that allows me to do a foreach on $schedule and it prints it out
and I have have tried in the foreach to:
echo utf8_decode($line).'<br>';
and that lets me run a foreach and it displays the lines but both these 'working' solutions strip out the tabs/spacing I need to break the lines into fields.
Any ideas on how I can either load this differently into an array that I can do a foreach on and parse it or is there a good way to show what control/character codes might be causing the crashes/hiccups?
Thanks