Php 按顺序将数组值插入表中
我得到了624幅图像,它们的名称如下:Php 按顺序将数组值插入表中,php,arrays,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
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>";
echo”“;
$oldIndex=0;
$row=1;
foreach($images作为$image)
{
if(substr($image,0,1)!=$oldIndex)
{
如果($row>1){echo”“;}
回声“;
$oldIndex=substr($image,0,1);
$row++;
}
回显“$image”;
}
回声“;
。。像这样的
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>";
echo”“;
对于($n=13;$n>=1;$n--)
{
回声“;
对于($e=1;$e)这听起来不错。你做了什么?遇到了错误吗?@Jason Eddite对旧代码说:“我想是这样的,但我需要它颠倒过来,我的意思是1n1e
是左上角,我希望它是左下角谢谢,我想这就是我要找的。”