얼마나 간단 할 지 모르겠지만 특정 폴더의 파일을 표시하는 스크립트를 사용하고 있습니다. 알파벳순으로 표시하고 싶습니다. 이렇게하는 것이 어려울까요?PHP (폴더) 파일 알파벳 순서로 나열 하시겠습니까?
if ($handle = opendir($mainframe->getCfg('absolute_path') ."/images/store/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (($file != "index.html")&&($file != "index.php")&&($file != "Thumbs.db")) {
$strExt = end(explode(".", $file));
if ($strExt == 'jpg') {
$Link = 'index.php?option=com_shop&task=deleteFile&file[]='.$file;
$thelist .= '<tr class="row0"><td nowrap="nowrap"><a href="'.$Link.'">'.$file.'</a></td>'."\n";
$thelist .= '<td align="center" class="order"><a href="'.$Link.'" title="delete"><img src="/administrator/images/publish_x.png" width="16" height="16" alt="delete"></a></td></tr>'."\n";
}
}
}
}
closedir($handle);
}
echo $thelist;
: 대신 단순히 scandir
(documentation)를 사용할 수 readdir
를 사용
아, 그게 매력처럼 끝내 주셔서 고마워요. D – SoulieBaby
동일한 정확한 문제를 해결하는 동안이 대답을 찾았습니다. 감사! 적은 비용으로 잘 작동했습니다! – Agos
위대한 작품. 문서를 읽은 후에는'scandir (...) '의 두 번째 인수로'SCANDIR_SORT_DESCENDING'을 사용하여 정렬 순서를 바꿀 수도있었습니다. 제공되는 링크에는 몇 가지 다른 정렬 상수도 문서화되어 있습니다. –