jacko310592 Posted November 18, 2009 Share Posted November 18, 2009 hello guys, can anyone suggest a way the following Glob code can be altered to look for '.JPG' files as well as '.jpg' files $filecount = count(glob("{$dirLocation}/*.jpg")); thanks Link to comment https://forums.phpfreaks.com/topic/182059-solved-glob-look-for-jpg-as-well-as-jpg/ Share on other sites More sharing options...
cags Posted November 18, 2009 Share Posted November 18, 2009 A quick search of the manual for glob brought up a post by our very own Crayon Violent which indicates the glob regex supports basic alternation. It looks like you'd be looking for something like... $filecount = count(glob("{$dirLocation}/*.{jpg,JPG,jpeg,JPEG}")); NB: Untested. Link to comment https://forums.phpfreaks.com/topic/182059-solved-glob-look-for-jpg-as-well-as-jpg/#findComment-960367 Share on other sites More sharing options...
jacko310592 Posted November 18, 2009 Author Share Posted November 18, 2009 that code looks asif it should do the job perfectly, but for some reason im just receiving the count of '0', so it seems to over-looking all the images. but thanks for the response (Y) Link to comment https://forums.phpfreaks.com/topic/182059-solved-glob-look-for-jpg-as-well-as-jpg/#findComment-960377 Share on other sites More sharing options...
Ken2k7 Posted November 18, 2009 Share Posted November 18, 2009 <?php $filecount = intval(`ls {$dirLocation}/ | grep -i '\.jpg' | wc -l`); Edit: sorry, I had .txt when testing. Link to comment https://forums.phpfreaks.com/topic/182059-solved-glob-look-for-jpg-as-well-as-jpg/#findComment-960381 Share on other sites More sharing options...
cags Posted November 18, 2009 Share Posted November 18, 2009 OOops, I forgot the most important part, you must include the second argument as GLOB_BRACE. $filecount = count(glob("{$dirLocation}/*.{jpg,JPG,jpeg,JPEG}", GLOB_BRACE)); Link to comment https://forums.phpfreaks.com/topic/182059-solved-glob-look-for-jpg-as-well-as-jpg/#findComment-960385 Share on other sites More sharing options...
jacko310592 Posted November 18, 2009 Author Share Posted November 18, 2009 it worked :D thanks again cags Link to comment https://forums.phpfreaks.com/topic/182059-solved-glob-look-for-jpg-as-well-as-jpg/#findComment-960397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.