我有PHP的问题。它没有打印出我用readdir()
正确抓取的文件夹的名称
问题只出在波兰语中使用的单个字符。
<?php
//var with directory, put in the directory containing albums here
$main = "C:/Users/Jakub/Desktop/devving/gallery/images/";
$counter = 0;
$albumdata = [];
//gets all albums inside of the folder and stores inside of an array
if($opendir = opendir($main)){
while(($file = readdir($opendir)) !== false){
if($file == "." or $file == "..")continue;
$albumdata[$counter] = $file;
$counter += 1;
}
closedir($opendir);
$counter = 0;
}
//gets all files inside of albums and stores them inside of arrays with the names of the albums
for($i = 0;$i < count($albumdata); $i++){
if($opendir = opendir($main . $albumdata[$i])){
while(($file = readdir($opendir)) !== false){
if($file == "." or $file == "..") continue;
${$albumdata[$i]}[$counter] = $file;
$counter +=1;
}
closedir($opendir);
$counter = 0;
}
}
//echoes albums
for($i = 0;$i < count($albumdata); $i++){
$counter += 1;
if($counter == 1){
echo "<div class = 'firstimg'><a href = '"."images/".$albumdata[$i]."'><img src = '"."images/".$albumdata[$i]."/".${$albumdata[$i]}[0]."'><p>".$albumdata[$i]."</p></a></div>";
}else if($counter == 2){
echo "<div class = 'secondimg'><a href = '"."images/".$albumdata[$i]."'><img src = '"."images/".$albumdata[$i]."/".${$albumdata[$i]}[0]."'><p>".$albumdata[$i]."</p></a></div>";
}else{
echo "<div class = 'lastimg'><a href = '"."images/".$albumdata[$i]."'><img src = '"."images/".$albumdata[$i]."/".${$albumdata[$i]}[0]."'><p>".$albumdata[$i]."</p></a></div>";
$counter = 0;
}
}
&GT;
这是代码。 $ main目录中的相册名为Koty
,Krajobrazy
Ptaki
和Żaby
。问题出在最后一个问题上,而不是在段落中回显Żaby
它的来源与�aby
相呼应
编辑:忘了提,我可以单独回应。