Reply to Re: First 10 files

Your name:

Reply:


Posted by Rik on 03/05/07 15:36

sosoro <sosodotro@gmail.com> wrote:

> Source
> ----------------------------------------
> if (is_dir($dir))
> {
> if ($dh =3D opendir($dir))
> {
>
>
> while (($file =3D readdir($dh)) !=3D=3D false)
> {
> // Is it a valid extension?
> if(!is_dir($file) && is_numeric(strpos($file, ".")))
> {
> if($this->_IsValidExtension($file))
> $arrImages[] =3D $file;
> }
> }
> closedir($dh);
>
>
> }
> }
>
>
> How to change the code to have in $arrImages[] just the first 10
> files from that directory, not all files (Order: DESC or ASC).

$cur_dir =3D getcwd();
chdir($dir);
$arrImages =3D array_slice(glob(*.*),0,10);
//last 10: array_reverse(array_slice(glob(),-10,10);)
chdir($cur_dir);

Optionally with a somewhat better check then just '*.*'.
-- =

Rik Wasmus
Posted on Usenet: any site claiming this as original content or me as an=
=

contributing member is wrong.
Ask Smart Questions: http://tinyurl.com/anel

[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

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