I am trying to split the string below on all <br>
but for some reason my loop returns one giant string. I swear Im missing something simple but I cant see it. Thanks!
if(file_exists("/home/pi/Desktop/PiControl/status_log"))
{
$file = readfile("/home/pi/Desktop/PiControl/status_log");
$arr= explode("<br>",$file);
//$file=array_slice($file,count($file)-5);
//$file=array_reverse($file);
foreach($arr as $f)
{
echo $f;
echo "WOO";
}
fclose($file);
}
else
{
echo "no file found";
}
contents of the file:
<br>light is now: on 2015-06-01 03:32:42.902387<br>light is now: off 2015-06-01 03:32:54.360173<br>light is now: on 2015-06-01 03:33:07.781693<br>light is now: off 2015-06-01 03:33:15.867386<br>light is now: on 2015-06-01 03:34:42.683736<br>light is now: off 2015-06-01 03:34:45.205557<br>light is now: on 2015-06-01 03:36:18.037309<br>light is now: off 2015-06-01 03:36:25.915424<br>light is now: on 2015-06-01 03:36:58.261714<br>light is now: off 2015-06-01 03:37:05.103494<br>light is now: on 2015-06-01 11:00:01.735592<br>light is now: off 2015-06-01 13:06:50.254778<br>light is now: on 2015-06-01 17:28:11.218417
should return:
light is now: on 2015-06-01 03:32:42.902387
WOO
light is now: off 2015-06-01 03:32:54.360173
WOO
.....