我有這個問題,我想用opendir
這個數組的目錄,這有可能嗎?與固定的網址我可以讀取文件與readdir
。但我不知道如何處理多個目錄做...
創建數組:PHP opendir和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>";
}
和輸出例如:
網址/ PHP/1/
URL/JAVA/1/
URL/PHP/2/
URL /紅寶石/ 2/
URL/JAVA/2/
網址/ PHP/3/
網址/ PHP/4/
URL /紅寶石/ 4/
等
非常感謝你
我其實不明白,什麼是工作錯誤,你想實現什麼? – JTC
@JTC我不知道在哪裏找到'opendir'來讀取所有生成的目錄。我正在嘗試'foreach',但不起作用。謝謝 – santyas