Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
Last active December 12, 2015 01:08
Show Gist options
  • Save AmyStephen/4689192 to your computer and use it in GitHub Desktop.
Save AmyStephen/4689192 to your computer and use it in GitHub Desktop.
Freaking dots.
<?php
/**
* Discovery retrieves folder and file names
*
* @param $path
*
* @return void
* @since 1.0
*/
public function discovery($path)
{
$this->directories = array();
$this->files = array();
if (is_file($path)) {
$this->files[] = $path;
return;
}
if (is_dir($path)) {
} else {
return;
}
$this->directories[] = $path;
$objects = new RecursiveIteratorIterator (
new RecursiveDirectoryIterator($path),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($objects as $name => $object) {
if (is_file($name)) {
$this->files[] = $name;
} elseif (is_dir($name)) {
if (basename($name) == '.' || basename($name) == '..' ) {
} else {
$this->directories[] = $name;
}
}
}
return;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment