note 11427 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:08:29 +0000
Subject: note 11427 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126567@lists.php.net to get a copy of this message
Note Submitter: slicky at newshelix dot com ---- @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"))

« previous php.notes (#126567) next »