The following functions do not work when there is a space in the directory path. For example, the following path name indicates "Stack Overflow_files", which contains a space.
$dir = '/home/mamun/workspace/barj/barj/barj/Sequence/Stack Overflow_files';
$scanned_directory = array_diff(scandir($dir, 0), array('..', '.'))
or
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$scanned_directory[] = $filename;
}
I can find a solution from a terminal running ls '$ dir'. but is there any way in php to get a dirctory list?
source
share