You are here: Re: random pic - does not ALWAYS show « PHP Programming Language « IT news, forums, messages
Re: random pic - does not ALWAYS show

Posted by Jerry Stuckle on 01/25/07 14:15

Geoff Berrow wrote:
> Message-ID: <djpgr21fg61gl5sl97c8ag385sibd7gfge@4ax.com> from Geoff
> Berrow contained the following:
>
>> $files = glob("./gfx/zufall/*");
>> shuffle ($files);
>> foreach( $files as $key=>$value){
>> if ($value=="." || $value==".."){
>> unset($files[$key]);
>> }
>> }
>>
>> echo "<a href='index.php'><img src='".$file[0]."' height='341'
>> width='634' border='0'></a>";
>> }
>> ?>
>
> Ummm, that should be:-
>
> $files = glob("./gfx/zufall/*");
> shuffle ($files);
> foreach( $files as $key=>$value){
> if ($value=="." || $value==".."){
> unset($files[$key]);
> }
> }
> echo "<a href='index.php'><img src='".$files[0]."' border='0'></a>";
>

Close, Goeff. But I think you want to remove the pseudo-files before
you shuffle. What happens if after the shuffle one of them comes up as
element 0?

Just putting the shuffle() after the foreach loop should work better.

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

 

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

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