Voting

: max(eight, three)?
(Example: nine)

The Note You're Voting On

Michael mt1955 (a) gmail.com
18 years ago
# 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);
?>

<< Back to user notes page

To Top