按顺序将数组值插入表中

时间:2013-03-29 12:09:32

标签: php arrays

我得到了一组624张图像,女巫的名字如下:

1n1e.png
1n2e.png
..
2n1e.png
2n2e.png

等等。最大'n'值为13,最大'e'值为48,我的意思是 - 13n48e

我想创建一个13x48表,并相应地放置所有这些图像。

1n1e is located in bottom left corner, 
13n1e is at the top left corner, 
13n48e at the top right corner, 
1n48e at the bottom right corner.

编辑:我有这个旧代码,但它无法正常工作:

echo "<table border='1'>";
$oldIndex=0;
$row=1;
foreach($images as $image)
{
    if(substr($image,0,1)!=$oldIndex)
    {
    if($row>1){echo "</tr>";}

    echo "<tr>";
    $oldIndex=substr($image,0,1);
    $row++;
    }
    echo "<td>$image</td>";

}

echo "</table>";

1 个答案:

答案 0 :(得分:0)

..这样的事情?

echo "<table>";
for( $n =13; $n >= 1; $n-- )
{
    echo "<tr>";
    for ( $e = 1; $e <= 48; $e++ )
    {
         echo "<td>";
         echo image $n $e
         echo "</td>";

    }
    echo "</tr>";
}
echo "</table>";