聊天系统日志问题

I've made a chat system with jquery and php and ajax, and I want the chat window to display the last 10 lines of the html log.

the log.html looks something like this:

<div class='msgln'><b>Brian</b>: dd<br></div><div class='msgln'><b>Brian</b>: ddf<br></div><div class='msgln'><b>Arne</b>: PIS!<br></div><div class='msgln'><b>Brian</b>: sdfsdf sdfsdffds sdfdsf sdf sdf  dfs dfsdf sdf sfd  sfd  fsd fsd sdf  sdffsd sd fsdfsd fsd fsd<br></div><div class='msgln'><i>Brian er kommet på chatten.</i><br></div>

My php looks like this now:

echo "<div id='chatbox'>";
if(file_exists("log.html") && filesize("log.html") > 0){
$handle = fopen("log.html", "r");
$contents = fread($handle, filesize("log.html"));

fclose($handle);

$lastfifteenlines = array_slice(explode("<br>",file_get_contents($contents)),-10);

echo $lastfifteenlines;
}
echo "</div>";

But it's showing everything from the log...

How can I show only the last 10 lines? The last 10 times that br occurs?

edit:

ajax and jquery:

function loadLog(){     
var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20; //Scroll height before the request
$.ajax({
url: "log.html",
cache: false,
success: function(html){        
$("#chatbox").html(html); //Insert chat log into the #chatbox div   

//Auto-scroll           
var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20; //Scroll height after the request
if(newscrollHeight > oldscrollHeight){
$("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal'); //Autoscroll to bottom of div
}               
},
});
}
function get_last_lines($fp, $num)
{
    $idx   = 0;

    $lines = array();
    while(($line = fgets($fp)))
    {
        $lines[$idx] = $line;
        $idx = ($idx + 1) % $num;
    }

    $p1 = array_slice($lines,    $idx);
    $p2 = array_slice($lines, 0, $idx);
    $ordered_lines = array_merge($p1, $p2);

    return $ordered_lines;
}

// Open the file and read the last 15 lines
$fp    = fopen('log.html', 'r');
$lines = get_last_lines($fp, 15);
fclose($fp);

// Output array
print_r($lines);

Try this by your self.