Skip to content

@pwlin /gist:3038377
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
RecursiveDirectoryIterator
<?php
// walks a directory recursively
// calls at each file $function with the file as argument and $baseArgs as additional arguments
function walkRecursivelyDF($dir, $function, $baseArgs) // depth first
{
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $path) {
if ($path->isDir()) {
if (substr($path->__toString(), -2) == '/.')
continue;
if (substr($path->__toString(), -3) == '/..')
continue;
}
call_user_func_array($function, array($path->__toString(), $baseArgs));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.