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);
}
...
Ich benutze es in Wordpress, und die Seite lädt ziemlich langsam, aber es könnte auch von vielen Bildern sein. Ich wollte nur sicherstellen, dass ich nicht etwas mache, das aus Performancegründen verpönt ist.Ist das PHP opendir() sehr anstrengend auf dem Server?