Voting

: min(six, nine)?
(Example: nine)

The Note You're Voting On

Anonymous
9 years ago
I always wanted something like this to avoid listing all the files and folders you want to exclude in a project directory.

function array_preg_diff($a, $p) {
foreach ($a as $i => $v)
if (preg_match($p, $v))
unset($a[$i]);
return $a;
}

$relevantFiles = array_preg_diff(scandir('somedir'), '/^\./');

instead of

$relevantFiles = array_diff(scandir('somedir'), array('.', '..', '.idea', '.project));

<< Back to user notes page

To Top