First 10 files

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
    if (is_dir($dir))
            if ($dh = opendir($dir))

                while (($file = readdir($dh)) !== false)
                    // Is it a valid extension?
                    if(!is_dir($file) && is_numeric(strpos($file, ".")))
                        $arrImages[] = $file;


How to change the code to have in $arrImages[]  just the first 10
files from that directory, not all files (Order: DESC or ASC).


Re: First 10 files

Quoted text here. Click to load it

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

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:

Site Timeline