我对PHP很新,有点筋疲力尽,所以我需要对我的问题提出一些建议。
我写" for"用"开关"函数,但代码只返回第一个循环结果(我有5个循环),然后将默认值赋给变量。我究竟做错了什么?我猜很多。
$oblaki1 = $xml1->metData[10]->nn_shortText_domain_top;
.
.
.
$show1 = "";
$show2 = "";
.
.
.
$bar = array("$oblaki1","$oblaki2","$oblaki3","$oblaki4","$oblaki5","$oblaki6");
$show = array("$show1","$show2","$show3","$show4","$show5","$show6");
for ($i = 0; $i <= 5; $i++){
switch ($bar[$i]){
case "FG":
show[$i] = "<img src='local/baz.png'height='70'width='70' /> ";
break;
case"DZ";
$show[$i] = "<img src='local/bar.png' height='70' width='70' /> ";
break;
.
.
.
.
}
}
echo "$show[0]";
echo "$show[1]";
.
.
.
因为同样的$ bar []可能是emty,后来我也检查了$ foo [],它总是被占用:
$foo = array("$padavine1","$padavine","$padavine3","$padavine4","$padavine5","$padavine6");
for ($i = 0; $i <= 5; $i++){
switch ($foo[$i]){
case "XY":
show[$i] = "<img src='local/XY.png'height='70'width='70' /> ";
break;
case"XX";
$show[$i] = "<img src='local/XX.png' height='70' width='70' /> ";
break;
.
.
.