【发布时间】:2014-04-14 04:26:56
【问题描述】:
我正在尝试在 5 x 3 表中显示图像。
如果全部为空(blank.png),我可以显示图像。
这里是代码
<?PHP
$ds ='\image';
$imagefile = array("EX_W1_01.png", "EX_W1_02.png", "EX_W2_01.png","EX_W3_01.png");
echo "<pre>"; print_r($imagefile);
$file = 'blank.png';
$d = $ds.$file;
echo "<table border = 1 width=\"540px\" cellspacing=\"0px\" cellpadding=\"0px\">";
for($row=1;$row<=5;$row++){
echo "<tr>";
for($col=1;$col<=3;$col++){
// echo"<td height=60px>W$row</td>";
//if()
echo"<td height=60px>W$row<img border = 1 height = 120 width = 120 src = $d ></td>" .PHP_EOL;
}
echo "</tr>";
}
echo "</table>";
?>
我想显示基于中间文件名数组$imagefile eg W1, W2的图像,如果不在数组中,我将显示blank.png。
我能够通过此代码获取中间文件名,但我无法在正确的行/列中显示图像。
for($i=0;$i<count($imagefile); $i++) {
$wd = substr($imagefile[$i], 3, strpos($imagefile[$i], '_'));
}
【问题讨论】:
-
数组中列出的图片是否也在
\image路径下? -
是相同的路径只显示不同的图像。
标签: php html loops html-table nested