0

我有这个问题,我想opendir用这个目录数组,可以吗?使用固定的 url,我可以使用readdir. 但我不知道如何处理多个目录...
创建数组:

$results = mysqli_query($connecDB,"SELECT * FROM brands WHERE 1 IN (php, ruby, java) ORDER BY id ASC");

//select all records with value "1" in different columns "php ruby java".
// The value "1" indicates a folder created named $id in php, ruby and/or java folder

$resultsArray = array();

while($row = mysqli_fetch_assoc($results)){
    if($row['php'] == 1) {
        $resultsArray['php'][] = $row['id'];
    }
    if($row['java'] == 1) {
        $resultsArray['java'][] = $row['id'];
    }
    if($row['ruby'] == 1) {
        $resultsArray['ruby'][] = $row['id'];
    }
}

foreach($resultsArray as $language => $array){
    echo "url/" . $language . "/" . $row['id'] . "<br>";
}

以及输出示例:
url/php/1/
url/java/1/

url/php/2/
url/ruby/2/
url/java/2/

网址/php/3/

url/php/4/
url/ruby/4/


非常感谢

4

2 回答 2

1
foreach($resultsArray as $language => $array){
    foreach(array_slice(glob('work/'.$language.'/'.$rowtest['id'].'/*.jpg'),0,1) as $image){    
        echo $image . "<br />";
    }
}
于 2013-08-20T18:31:54.940 回答
0

您可以在 foreach 循环中一个接一个地读取目录。究竟是什么问题?

于 2013-08-20T14:54:08.603 回答