note 11427 added to readdir
| From: | slicky at newshelix dot com | Date: | Tue, 20 Feb 2001 16:52:52 +0000 |
| Subject: | note 11427 added to readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11312@lists.php.net to get a copy of this message | ||
@dwalet@po-box.mcgill.ca
To search for some specific file or file extension:
Make sure that you put this expression
if (ereg("\.sql",$file)) instead of (eregi(".sql",$file)) since the ereg
function is familiar with regular expressions
and "the point" (any char) represents a special reg expr. (have a look at reg expr. if you
are interested!)
You can combine in the if expression whatever you want for instance if
(ereg("\.sql",$file)) && (strlen($file))<100 )
:) of course this doesn't make sooo much sense to use a strlen here, but however this should
only be a demonstration
Now the next thing...
Speed issue :
Since the ereg() is capable of reg expr. this means a high speed decrease for you.
So for this simple fileextension search function use the strstr() function instead... which
hasn't the power of reg expr. but boast of speed
At least your "if expression" should look something like that:
if(stristr($file,".sql"))
http://www.php.net/manual/en/function.readdir.php