simple javascript problem
<p>Hi i have some simple javascript which is reading from a text file and placing the text on to this form.</p>

<p>The problem i'm having is im struggling to work out how to change 'count' to only show the last 5 lines of the text file instead of every single line.</p>

<p>//php file</p>

<pre><code>&lt;?
 case 'view':
      $data = array();
      $arr = file('messages.php');
      if(!$_GET['time'])
        $_GET['time'] = 0;
      foreach($arr as $row) {
        $aTemp = null;
        list($aTemp['time'], $aTemp['nickname'], $aTemp['message']) = explode('|', $row, 5); 
        if($aTemp['message'] AND $aTemp['time'] &gt; $_GET['time'])
          $data[] = $aTemp;
      }
      //file_put_contents('debug.txt', print_r($data, true));
    break;
  }

  require_once('JSON.php');
  $json = new Services_JSON();
  $out = $json-&gt;encode($data);
  print $out;

?&gt;
</code></pre>

<p>// form page</p>

<pre><code>var count = 0;
function prepare(response) {
          var d = new Date();
          count++;
          d.setTime(response.time*1000);
          var mytime = d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
          var string = '&lt;div class="shoutbox-list" id="list-'+count+'"&gt;'
              + '&lt;span class="shoutbox-list-time"&gt;'+mytime+'&lt;/span&gt;'
              + '&lt;span class="shoutbox-list-nick"&gt;'+response.nickname+':&lt;/span&gt;'
              + '&lt;span class="shoutbox-list-message"&gt;'+response.message+'&lt;/span&gt;'
              +'&lt;/div&gt;';

          return string;
        }

    function success(response, status)  { 
      if(status == 'success') {
        lastTime = response.time;
        $('#daddy-shoutbox-response').html('&lt;img src="'+files+'images/accept.png" /&gt;');
        $('#daddy-shoutbox-list').append(prepare(response));
        $('input[@name=message]').attr('value', '').focus();
        $('#list-'+count).fadeIn('slow');
        timeoutID = setTimeout(refresh, 3000);
      }
    }
</code></pre>
