i have following code displays file names in specified folder. but, when there 1 file in folder, file not displayed.
what doing wrong?
$files = glob("images/properties/*.*"); ($i=1; $i<count($files); $i++) { $image = $files[$i]; echo '$image'; }
php indexes arrays 0. since you're starting loop @ 1, you're skipping first matched file. , in fact, for() loop pointless, do
foreach($files $i => $file) { ... } and not have worry counting or terminating loop properly.
Comments
Post a Comment