You are here: Re: How read ONLY last row ASCII fil.e « PHP Language « IT news, forums, messages
Re: How read ONLY last row ASCII fil.e

Posted by Kimmo Laine on 02/10/07 15:39

OmegaJunior wrote:
> On Thu, 08 Feb 2007 08:25:16 +0100, Ilkka Maatta <ilkka.maatta@phnet.fi>
> wrote:
>
>> PHP code .....
>>
>> <?
>> //Open file.
>> $file=fopen("file.txt","r");
>> //read file so long when it isn't end.
>> while (!feof($file))
>> {
>> //read and print row + LF.
>> $rivi=fgets($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 = file('file.txt');
> print($aF[$aF.length-1]);
> ?>
>

Don't know what this guys problem is, but this is the third group where
he's asking the same thing and like 10th reply saying the same thing.
And yet he fails to understand. It's quite amazing really. Hydrogen and
stupidity...

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация