Skip to content

Instantly share code, notes, and snippets.

@Darfk
Last active December 22, 2015 08:39
Show Gist options
  • Save Darfk/6446846 to your computer and use it in GitHub Desktop.
Save Darfk/6446846 to your computer and use it in GitHub Desktop.
Returns a flat array of all the files in $d relative to $d.
<?php
// Returns a flat array of all the files in $d
function scandir_recursive ( $d, $b = '' )
{
$ls = scandir ( $d );
$a = array();
foreach ( $ls as $v )
{
if ( $v == '.' || $v == '..' ) continue;
if ( is_dir ( $d . '/' . $v ) )
{
$a = array_merge ( scandir_recursive ( $d . '/' . $v, $v ), $a );
}
else
{
$a []= $b . '/' . $v;
}
}
return $a;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment