Page 1 of 1

Search and glob

Posted: Sun Apr 23, 2006 11:01 am
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!

Posted: Sun Apr 23, 2006 11:02 am
by John Cartwright
huh?

define "a search"

Posted: Sun Apr 23, 2006 1:07 pm
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.)