基本上我想创造的东西,让我做这件事:如何在PHP中创建分段的foreach()函数?
<?php
function herp(){foreach($users as $user):}
function derp(){endforeach;}
?>
<html><body>
<?php herp();?>
<?php $user->name();?>,<?php $user->name();?>,<?php $user->name();?>
<?php derp();?>
</body></html>
--------- output ---------
John Doe, 1900, Buttery Yellow
Jane Doe, 1900, Platypus Brown
我不想创建或依赖模板引擎。我只是想让它创建页面模板的人可以为他提供循环。
'make'绝对不是一个恰当的标签! –
结帐[小胡子](http://mustache.github.com/) - https://github.com/bobthecow/mustache.php – hakre
你不能像这样分割出一个'foreach','endforeach'就是预计将在相同的范围内。 – CodeCaster