You are here: Re: order by file name readdir() « PHP Programming Language « IT news, forums, messages
Re: order by file name readdir()

Posted by MZ on 04/15/07 19:14

Uytkownik "MZ" <marcinzmyslowski@poczta.onet.pl> napisa w wiadomoci
news:evtrkn$618$1@news.onet.pl...
>
> Uzytkownik "Tim Van Wassenhove" <timvw@users.sourceforge.net> napisal w
> wiadomosci news:LqOdnYK4zsK_h7_bnZ2dnUVZ8sSrnZ2d@scarlet.biz...
>> MZ schreef:
>>> Unfortunately images are not sorted by filename and I don`t know why.
>>
>> From: http://www.php.net/readdir
>> Returns the filename of the next file from the directory. The filenames
>> are returned in the order in which they are stored by the filesystem.
>>
>> So you still have to add code that sorts the filenames by name..
>>
>> eg:
>>
>> $filenames = array();
>> while ($filename = readdir($dir)) {
>> $filenames[] = $filename;
>> }
>>
>> sort($filenames);
>>
>> foreach($filename in $filenames) {
>> echo $filename . '<br/>';
>> }
>
>
> Thank you very much for help..
>
> There is little error in the code. It should be:
>
> foreach($filenames in $file) {
> echo $file . '<br/>';
> }
>
>
> Cheers, thanx, hugs
> Marcin
>

Sorry it should be::

foreach($filenames as $file)
{
echo $file . '<br/>';
}

 

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

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