Reply to Re: readdir() doesn't maintain order

Your name:

Reply:


Posted by Jerry Stuckle on 09/16/07 12:06

Confused but working on it wrote:
> On 2007-09-15 09:03:24 -0700, Andy Hassall <andy@andyh.co.uk> said:
>
>> On Sat, 15 Sep 2007 08:10:46 -0700, Semi Confused
>> <PostInGroups@wherever.com>
>> wrote:
>>
>>> $dir = opendir("thumbs");
>>> //read files in the dir
>>> while (($file = readdir($dir)) !== false)
>>>
>>> Was reviewing a few of the pages I made and something seemed odd.
>>> Further investigation showed that my thumbs are not in the order of
>>> the filesystem.
>>> So it starts at pic 1370 and ends back at 1359. In reality the pics
>>> start at 1359 and end at 1424. Maybe the question is how is the file
>>> system really sorted?
>>
>> Yes.
>>
>>> I haven't tried to implement the other methods shown this week and
>>> maybe one doesn't do this?
>>> or
>>> Readdir into an array?
>>
>> Yes, or scandir() (which gives a sorted array), or glob() (which both
>> filters
>> and sorts), but in either case you may still want a different sort
>> order - in
>> particular look at natsort().
>>
>> http://php.net/scandir
>> http://php.net/glob
>> http://php.net/natsort
>
> So I kludged this together and it doesn't fail but doesn't display my
> image after I click the thumb. glob() says it searches for all pathnames
> so if the file was where the code is then the filname is the pathname. I
> think. when i mouseover I can see that the path for the image has
> "thumbs" in it as it is part of the path from blob().
>
> <?php
> foreach (glob("thumbs/*.jpg") as $file)
> echo "<a href='images/$file'><img src='$file'
> class=\"pad1em\"></a>";
> ?>
>
> How do I remove the thumbs from the link on the echo?
>

Maybe something like

str_replace('thumbs/', '', $file);

> I think you guys are messing with me. :)
>

And why would we do that?

> Thanks,
> Ron
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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