Explode your log file by linebreaks to get an array. Reverse your array, and now you can search line by line from the end.
$lines = explode("\n",$body);
$reversed = array_reverse($lines);
foreach($reversed AS $line) {
// Search for your keyword
}
If you are talking about a massive log file, such that you absolutely do not want to read it all into memory, you could also look at a reverse seek approach, though that's typically not needed. See here: