if (is_dir($dir)) {
if($handle = opendir($dir)) {
while($file = readdir($handle)) {
// Break the filename by period; if there's more than one piece, grab the last piece.
$parts = explode(".", $file);
if (is_array($parts) && count($parts) > 1) {
$ext = end($parts);
// If it's an image that we want, echo the code.
if ($ext == "png" OR $ext == "PNG" OR $ext == "jpg" OR $ext == "JPG" OR $ext == "jpeg" OR $ext == "JPEG" OR $ext == "gif" OR $ext == "GIF")
echo "<img src=\"$path/$file\" />";
}
}
closedir($handle);
}
...
Wordpress에서 사용하고 있으며 페이지로드가 매우 느리지 만 많은 이미지가있는 것일 수도 있습니다. 나는 단지 성능상의 이유로 눈살을 찌푸린 뭔가를하지 않기를 원했다.이 PHP opendir()이 서버에 과연 부담이됩니까?