glob() syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
db579
Forum Commoner
Posts: 37
Joined: Sun Jul 18, 2010 6:23 pm

glob() syntax

Post by db579 »

Have been reading the glob() manual but can't seem to find any syntax for finding all files that don't match a pattern. For example I have this

Code: Select all

$picture_array = glob("$album/*_th.jpg");
which returns all files ening in _th.jpg. What I actually want it to do is return all files that DON'T end in that. How would I do this? Thanks
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: glob() syntax

Post by AbraCadaver »

You can't. glob() supports very limited regex, so glob for what you need like *.jpg and then when you loop through the array use a strpos() or preg_match() to eliminate the ones you don't want.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply