我想回到foreach语句中,如下面的示例代码所示。 有没有办法做到这一点?嵌套html与PHP foreach语句
<?php
foreach($boxes as $box)
{
foreach($box as $thing)
{
?>
<img src="<?php echo $thing ?>"/>
<?php
}
}
?>
<!-- more html code here outside of foreach statement that don't want to be loop -->
// want to go back in to the foreach statement
<?php echo $thing; ?>
所以输出将
<img src="1">
<img src="2">
<img src="3">
<div>this only appear once</div>
<img src="1"><p>1</p>
<img src="2"><p>2</p>
<img src="3"><p>3</p>
我想再次以相同的顺序打印出相同的东西。不确定插值是什么意思。 – aahhaa 2014-12-05 04:05:55
难道你只是再次运行循环? (在你需要的下一节中有另一个'foreach'循环吗?) – Darren 2014-12-05 04:06:39
将foreach结果保存到一个变量中,然后在你想要的地方打印变量? – Prix 2014-12-05 04:06:55