You are here: Re: [PHP] Find largest integer filename « PHP « IT news, forums, messages
Re: [PHP] Find largest integer filename

Posted by Tom Rogers on 07/06/05 09:19

Hi,

Wednesday, July 6, 2005, 2:43:38 PM, you wrote:
RL> Suppose I have a directory with a HUGE number of filenames, all of which
RL> happen to look like integers:

RL> ~/nntp/1
RL> ~/nntp/2
RL> ~/nntp/3
RL> .
RL> .
RL> .
RL> ~/nntp/59874
RL> ~/nntp/59875
RL> ~/nntp/59876

RL> Now, in a PHP script, what's the most efficient way to find the "largest"
RL> filename, where "largest" means in the sense of an integer, not a string?

RL> I could probably force the filenames to be 0-padded if that would make a
RL> significant difference.

RL> Is there some nifty shell command I should just "exec"?...

RL> I don't really care which shell, but I'm a bash user generally.

RL> Obviously I could loop through all the filenames, so I'm looking for
RL> something faster than that. :-)

RL> --
RL> Like Music?
RL> http://l-i-e.com/artists.htm


You could try:

$last = exec('ls -D /fullpath/nntp | sort -n');
echo "Largest: $last<br>";

--
regards,
Tom

 

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

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