|
Posted by OmegaJunior on 02/09/07 06:50
On Thu, 08 Feb 2007 08:25:16 +0100, Ilkka Maatta <ilkka.maatta@phnet.fi>=
=
wrote:
> PHP code .....
>
> <?
> //Open file.
> $file=3Dfopen("file.txt","r");
> //read file so long when it isn't end.
> while (!feof($file))
> {
> //read and print row + LF.
> $rivi=3Dfgets($file,1024);
> print "$row<BR>";
> }
> //Close file.
> fclose($file);
> ?>
>
> ....is read file(ascii) and print it display.
>
> How i can read and print only last row - don't all row?
>
>
>
>
With the file() command you retrieve all the lines in the file into an =
array. Then you can print the last element of the array and discard the =
=
rest:
<?php
$aF =3D file('file.txt');
print($aF[$aF.length-1]);
?>
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Navigation:
[Reply to this message]
|