我有这个问题,我想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/
等
非常感谢