note 90468 added to function.is-file

From: Date: Thu, 23 Apr 2009 19:24:30 +0000
Subject: note 90468 added to function.is-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-153635@lists.php.net to get a copy of this message
this is a simple way to find specific files instead of using is_file(). this example is made for mac standards, but easily changed for pc. function isfile($file){ return preg_match('/^[^.^:^?^\-][^:^?]*\.(?i)' . getexts() . '$/',$file); //first character cannot be . : ? - subsequent characters can't be a : ? //then a . character and must end with one of your extentions //getexts() can be replaced with your extentions pattern } function getexts(){ //list acceptable file extensions here return '(app|avi|doc|docx|exe|ico|mid|midi|mov|mp3| mpg|mpeg|pdf|psd|qt|ra|ram|rm|rtf|txt|wav|word|xls)'; } echo isfile('/Users/YourUserName/Sites/index.html'); ---- Server IP: 69.147.83.197 Probable Submitter: 67.187.135.105 ---- Manual Page -- http://www.php.net/manual/en/function.is-file.php Edit -- https://master.php.net/note/edit/90468 Del: integrated -- https://master.php.net/note/delete/90468/integrated Del: useless -- https://master.php.net/note/delete/90468/useless Del: bad code -- https://master.php.net/note/delete/90468/bad+code Del: spam -- https://master.php.net/note/delete/90468/spam Del: non-english -- https://master.php.net/note/delete/90468/non-english Del: in docs -- https://master.php.net/note/delete/90468/in+docs Del: other reasons-- https://master.php.net/note/delete/90468 Reject -- https://master.php.net/note/reject/90468 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153635) next »