$file=file("log.html"); $count=count($file); for($i=$count;$i>=(($count)-40);$i--){ $log.=$file[$i]."\r\n"; }