It's nice to be able to generate an html table from a PHP array. I know how to
do this, but the array in question is built from a file. The file in question
can be very long, and I only want the first 10 lines. So, I'd like to reduce
the overhead it takes to read the file into the array by limiting the number of
lines read in - rather than have the entire file read in and then limiting the
output to the html table.
$visits= file("visdata.t xt");
//reverse the array so table is ordered by date decending
$visits = array_reverse ($visits);
//show only the last 10 visitors
$number_of_visi ts = count($visits);
if ($number_of_vis its > 10)
{
$number_of_visi ts = 10;
}
echo
"<table border='0' cellspacing='1' width='500'>";
....
....
....
....
There must be a way to limit how many lines from the file are read into the
array -- any suggestions?
Thanks in advance.
do this, but the array in question is built from a file. The file in question
can be very long, and I only want the first 10 lines. So, I'd like to reduce
the overhead it takes to read the file into the array by limiting the number of
lines read in - rather than have the entire file read in and then limiting the
output to the html table.
$visits= file("visdata.t xt");
//reverse the array so table is ordered by date decending
$visits = array_reverse ($visits);
//show only the last 10 visitors
$number_of_visi ts = count($visits);
if ($number_of_vis its > 10)
{
$number_of_visi ts = 10;
}
echo
"<table border='0' cellspacing='1' width='500'>";
....
....
....
....
There must be a way to limit how many lines from the file are read into the
array -- any suggestions?
Thanks in advance.
Comment