Created
December 30, 2017 16:05
-
-
Save codersaiful/38fb69a8d7956234a4b88b8bf02d45d1 to your computer and use it in GitHub Desktop.
Getting Directory Details Sultuion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Getting Details from a Directory. | |
* Project is coded by Saiful Islam. | |
* | |
* @author Saiful Islam <[email protected]> | |
* @package Saiful Script | |
* @link http://fb.com/codersaiful Saiful Islam Facebook Profile link. | |
*/ | |
function getDirDetails($dir){ | |
$files = scandir($dir); | |
echo '<ul>'; | |
foreach($files as $key => $value){ | |
$path = realpath($dir.DIRECTORY_SEPARATOR.$value); | |
$type = explode('.', $value); | |
$type = end($type); | |
$class = (is_file($path) ? 'file file_type_' . $type . ' ' . $type : 'folder'); | |
if(!is_dir($path)) { | |
echo "<li class='{$class}'>$value</li>"; | |
} else if($value != "." && $value != "..") { | |
echo "<li class='{$class}'>$value</li>"; | |
getDirDetails($path); | |
} | |
} | |
echo '</ul>'; | |
} | |
getDirDetails(str_replace('\\', '/', __DIR__) . '/my_dir/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment