|
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]
|