/ Published in: PHP
An more advanced dir function. Now we got both dir, dir::regex and dir::wildcard
Expand |
Embed | Plain Text
class dir { { if($path == null and $i == null) $first = true; if($path == null AND $i == null) { { break; } } $dir = new DirectoryIterator($path); $ri = new RegexIterator($dir, '/^' . $dirs[$i] . '$/', RegexIterator::ALL_MATCHES); foreach($ri as $item) { { { $return_dirs[] = self::regex($regex, $path . '/' . $item[0][0], $i + 1); } else { $return_dirs[] = $path . '/' . $item[0][0]; } } } $return_dirs = array_filter($return_dirs, function($array){ return !empty($array); }); // Filter away empty elements { $return_dirs = call_user_func_array('array_merge', $return_dirs); // Make multidimentional arrays, into single dimention array } return $return_dirs; } { return self::regex($regex); } }
You need to login to post a comment.
