note 90468 modified in function.is-file by danbrown
| From: | danbrown@php.net | Date: | Thu, 23 Apr 2009 19:28:31 +0000 |
| Subject: | note 90468 modified in function.is-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153636@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.
<?php
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');
?>
--was--
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');
http://php.net/manual/en/function.is-file.php