repeat
最后更新于:2022-04-01 11:03:43
> 这个是foreach的别名, 为了兼容angular的repeat用法
~~~
<table>
<tr>
<td>编号</td>
<td>标题</td>
<td>作者</td>
<td>创建时间</td>
<td>操作</td>
</tr>
<tr php-repeat="$list as $article">
<td>{$article.id}</td>
<td>{$article.title}</td>
<td>{$article.author}</td>
<td>{:time_format($article['create_time'])}</td>
<td>
<a href="/article/detail?id={$article.id}">查看</a>
<a href="/article/del?id={$article.id}">删除</a>
</td>
</tr>
</table>
~~~
解析后:
~~~
<table>
<tr>
<td>编号</td>
<td>标题</td>
<td>作者</td>
<td>创建时间</td>
<td>操作</td>
</tr>
<?php foreach ($list as $article) { ?><tr >
<td><?php echo $article["id"]; ?></td>
<td><?php echo $article["title"]; ?></td>
<td><?php echo $article["author"]; ?></td>
<td><?php echo time_format($article['create_time']); ?></td>
<td>
<a href="/article/detail?id=<?php echo $article["id"]; ?>">查看</a>
<a href="/article/del?id=<?php echo $article["id"]; ?>">删除</a>
</td>
</tr><?php } ?>
</table>
~~~