dreamwest Posted June 27, 2009 Share Posted June 27, 2009 Im trying to only select files with a .jpg extension in a directory. Also i need to kill the script if it doesnt have any files with this extension in it. Heres what ive got so far $dir = '/home/user/public_html/pics/'; foreach(scandir($dir) as $file){ //kill the script if no files if ($file< 0){ echo "No files"; die(); } //if $file has a .jpg extension do something here } Quote Link to comment https://forums.phpfreaks.com/topic/163863-match-files/ Share on other sites More sharing options...
trq Posted June 27, 2009 Share Posted June 27, 2009 Your code makes little sense. Take a look at glob. Quote Link to comment https://forums.phpfreaks.com/topic/163863-match-files/#findComment-864584 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.