PHP的循环阵列 - HTML表格 [英] php looping array - html table

查看:126
本文介绍了PHP的循环阵列 - HTML表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

N 元素的数组,形式为:

 阵列(
    阵列(富,BAR),
    阵列(富,BAR),
    阵列(富,BAR)...

我想循环阵列上和一个HTML表显示出来。


解决方案

 &LT ;? $ bigArray =阵列(阵列(富,酒吧),阵列(富,酒吧),阵列(富,酒吧)); ?>
<表>
&LT ;?的foreach($ bigArray为$ a){&GT?;
    &所述; TR>&所述;?为($ J = 0; $ J&下; = 5; ++ $ j)条{>?&下; TD>&下; = $一个[$ j]的>?&下; / TD>&所述;? }>< / TR>
&LT ;? ?}>
< /表>

这种方法的好处是,你可以原型与您最喜爱的HTML编辑器,插上的命令。需要注意的是这只能当你的服务器支持short_tags。

I have an array of n elements, of the form:

array (
    array ("FOO", "BAR"),
    array ("FOO", "BAR"),
    array ("FOO", "BAR")...
)

I would like to loop over the array and display them on an HTML table.

解决方案

<? $bigArray = array( array("foo", "bar"), array("foo", "bar"), array("foo", "bar") ); ?>
<table>
<? foreach($bigArray as $a) { ?>
    <tr><? for($j=0; $j <= 5; ++$j) { ?><td><?= $a[$j] ?></td><? } ?></tr>
<? } ?>
</table>

The advantage of this approach is that you can prototype with your favorite html editor and plug the commands in. Note that this only works when your server supports short_tags.

这篇关于PHP的循环阵列 - HTML表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆