note 75085 added to function.opendir

From: Date: Fri, 11 May 2007 14:59:06 +0000
Subject: note 75085 added to function.opendir
Groups: php.notes 
Request: Send a blank email to php-notes+get-126412@lists.php.net to get a copy of this message
# simple directory walk with callback function <?php function callbackDir($dir) { # do whatever you want here echo "$dir\n"; } function walkDir($dir,$fx) { $arStack = array(); $fx($dir); if( ($dh=opendir($dir)) ) { while( ($file=readdir($dh))!==false ) { if( $file=='.' || $file=='..' ) continue; if( is_dir("$dir/$file") ) { if( !in_array("$dir/$file",$arStack) ) $arStack[]="$dir/$file"; } } closedir($dh); } if( count($arStack) ) { foreach( $arStack as $subdir ) { walkDir($subdir,$fx); } } } walkDir($root,callBackDir); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 12.44.222.130 ---- Manual Page -- http://www.php.net/manual/en/function.opendir.php Edit -- https://master.php.net/note/edit/75085 Del: integrated -- https://master.php.net/note/delete/75085/integrated Del: useless -- https://master.php.net/note/delete/75085/useless Del: bad code -- https://master.php.net/note/delete/75085/bad+code Del: spam -- https://master.php.net/note/delete/75085/spam Del: non-english -- https://master.php.net/note/delete/75085/non-english Del: in docs -- https://master.php.net/note/delete/75085/in+docs Del: other reasons-- https://master.php.net/note/delete/75085 Reject -- https://master.php.net/note/reject/75085 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126412) next »