im trying to include the first 5 lines from a log file into a server monitoring script im working on.
I dont think you can include just a part of a file..
ever consider using XML for your log file?
much nicer and cleaner 😃 😃
but all that aside...
if you wanted to use a text file a 'easy' way to do it would be seperating ur log entries with a charater or somthing then exploding it...
like so...
This is inside your textfile....(textfile.txt)
logg entry #1[+]logg entry #2[+]logg entry #3[+]logg entry #4[+]logg entry#5[+]
logg entry #6[+]logg entry #7[+]logg entry #8[+]logg entry #9[+]logg entry #10[+]
this reads the file and displays the 1st 5 entrys...(reader.php)
$filename = 'textfile.txt';
$handle = fopen($filename, "r");
$log_string_buffer = fread($handle, filesize($filename)); //gets the contents of textfile.txt
fclose($handle);
$log_string = trim($log_string_buffer); // trims off the crap if there is any.
$log_array=explode('[+]',$log_string); //this explodes the string by [+]
//putting it into a nice array.
echo '5 latest log entries!:<br>';
for($i=0;$i<=4;$i++){
echo $log_array[$i].'<br>'; //echos out the 1st 5 entries!
}