Re: read -n lines from end of file - Empty array ?
| From: | Niels Andersen | Date: | Thu, 06 Mar 2003 19:56:48 +0000 |
| Subject: | Re: read -n lines from end of file - Empty array ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138510@lists.php.net to get a copy of this message | ||
$file = file('filename');
$line = end($file);
for ($i=0; $line && $i<10;$++)
{
list (..... and so on...
$line = prev($file);
}
"Webdev" <WebDev@browseabit.com> wrote in message
news:004b01c2e42f$46cc86c0$e8dcfea9@pc2jambb...
How to grab the last -n lines from a data file and display the stored data
Only the the last 10 line numbers coming back when I echo $i
How do I get the list($adnr, $user, $date, $listed .... to catch the
datafields
datafile looks like
23|Werner|LastN|Street|etc|etc.|etc||||||
24|Veronika||||
// code start
$file = file("data/ads.data");
for ($i = count($file); $i > count($file) - 10; $i--)
foreach($i as $line) {
list($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei, $vier,
$usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat,
$ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
$Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei,
$dreidrei, $dreivier, $dreifunf, $dreisechs ) = split ("\|", $buffer);
print " $i <a
href=\"classifieds.cgi?session_key=&search_and_display_db_button=on&db_id=$a
dnr&query=retrieval\" target=\"_blanko\">$Endzwei $End3</a>
<br>";
};
// Code end