如何添加< br/>在每个结果之后,但不是最后一个结果? [英] How to add a <br/> after each result, but not last result?
本文介绍了如何添加< br/>在每个结果之后,但不是最后一个结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的部分代码:
while($row = $db->fetch_array($query))
{
echo $row['row_name'];
}
我如何做到这一点,以便在每个结果之后添加一个break标签,而不是最后一个结果?
How can I make it so it will add a break tag after each result, but not the last result?
推荐答案
Put the output into an array, then join the array with implode
:
$rows = array();
while($row = $db->fetch_array($query))
{
$rows[] = $row['row_name'];
}
echo implode('<br/>', $rows);
这篇关于如何添加< br/>在每个结果之后,但不是最后一个结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文