2016-09-17 35 views

回答

0

這只是爲匹配通配符的所有文件獲取目錄列表的問題。在你的情況下,*.jpg。 您可以使用glob函數,然後使用forEach循環遍歷匹配文件名列表。

<?php 
// Creates a page full of jpg images found in the specified directory (current one if none specified) 
function showFiles($findMe) 
{ 
    foreach (glob($findMe) as $filename) 
      echo "<img src='$filename'/>"; 
} 
showFiles("*.jpg"); 
?> 
相關問題