Search and glob

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
User avatar
ozzy
Forum Commoner
Posts: 74
Joined: Tue Apr 11, 2006 4:45 pm

Search and glob

Post by ozzy »

How would i go about adding a search to the glob function?

eg of glob function:

Code: Select all

<?php
foreach (glob("*.txt") as $filename) {
   echo "$filename size " . filesize($filename) . "\n";
}
?>
Thanks in advance!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

huh?

define "a search"
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

There is already a 'search', since you only allow filenames that match the '*.txt' pattern... ;)

Anyway, you could use eg: http://www.php.net/preg_match to see if the filename matches another pattern... (Or any other string function that allows you compare (specific) parts.)
Post Reply