Here is my code:
What is does is grab a listing of certain file types and directories in a path.PHP Code:<?php
$search = $_SERVER['DOCUMENT_ROOT'] . '/data/';
$folders = str_replace($search, '', glob($search . '*', GLOB_ONLYDIR));
$filesExt = str_replace($search, '', glob($search . '*.[dDxXpPtT][oOlLpPdDxX][cCsStTfF]'));
$filesExtx = str_replace($search, '', glob($search . '*.[dDxXpP][oOlLpP][cCsStT][xX]'));
$files = array_merge($filesExt, $filesExtx);
sort($files);
foreach ($files as $file) {
echo $file . '<br />';
}
?>
Then, I am trying to sort the $files array alphabetically but the output is this:
Book1.xls
Book1.xlsx
Book2.xlsx
Book3.xlsx
aBook1 - Copy (3).xlsx
apple.doc
links - Copy (2).txt
links - Copy.txt
links.txt
test.doc
test.docx
What am I doing wrong?



Reply With Quote


Bookmarks