You are here: Re: order alfabetical many images « PHP Programming Language « IT news, forums, messages
Re: order alfabetical many images

Posted by jamen on 11/20/58 11:29

Davide wrote:
> Hi all.
>
> With this simple script I can see all my jpg in a web page..
> but they are confused randomly in the page.

> <?php
> if ($handle = opendir('/cover')) {
> while (false !== ($file = readdir($handle))) {
> if (($file != "." && $file != "..")) {
> echo " <img src=\"cover/$file\" alt=\"$file\" border=0> ";
> }
> }
> closedir($handle);
> }
>
> ?>
>

Put all the files in an array and sort it, then print

$files = array();

if (($file != "." && $file != "..")) {
$files[] = $file
}


all done:

asort($files);

for each($files as $file){
echo " <img src=\"cover/$file\" alt=\"$file\" border=0> ";
}

 

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

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