note 54388 added to function.is-dir
| From: | fanfatal at fanfatal dot pl | Date: | Sat, 02 Jul 2005 16:04:53 +0000 |
| Subject: | note 54388 added to function.is-dir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91314@lists.php.net to get a copy of this message | ||
Hi
I wrote an usefull function to check is directory exists in directory's tree ;)
<?php
/*
* Function to check recursively if dirname is exists in directory's tree
*
* @param string $dir_name
* @param string [$path]
* @return bool
* @author FanFataL
*/
function dir_exists($dir_name = false, $path = './') {
if(!$dir_name) return false;
if(is_dir($path.$dir_name)) return true;
$tree = glob($path.'*', GLOB_ONLYDIR);
if($tree && count($tree)>0) {
foreach($tree as $dir)
if(dir_exists($dir_name, $dir.'/'))
return true;
}
return false;
}
?>
Greatings ;)
...
----
Manual Page -- http://www.php.net/manual/en/function.is-dir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54388
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54388&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54388&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54388&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54388&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54388&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54388&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54388&report=yes
Search -- http://master.php.net/manage/user-notes.php