PHP解析数组添加css
我有以下代码:
while($row = mysql_fetch_array($result)){
$output_items[] = $row["title"]; } // while
print(implode("\n", $output_items));
它执行它所说的操作,并为每个项目用一个新行分割数组。
但我该如何做同样的事情并允许使用 ie 进行格式化我基本上想说的是
foreach of the $output_items echo "<div class=whatever>$output_items</div> etc etc
用这个撕掉我的头发!
非常感
谢达伦的帮助
I have the following code:
while($row = mysql_fetch_array($result)){
$output_items[] = $row["title"]; } // while
print(implode("\n", $output_items));
Which does what it says and splits the array with a new line for each item.
But how do I do the same and allow formatting with i.e. I basically want to say
foreach of the $output_items echo "<div class=whatever>$output_items</div> etc etc
Tearing my hair out with this!
Many thanks for all help
Darren
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不起作用?或者我没有得到你正在寻找的东西
doesn't work? or i did not get what you are searching for
非常简单,为了更容易阅读,我会这样做:
尽管您仍然可以很容易地使用原始代码执行此操作:
Pretty simple, to make it easier to read I'd do something like this:
Although you could still do this with your original code pretty easily:
使用字符串插值将它们添加在一起,而不是用
implode()
将它们全部换行:Rather than
implode()
them all with line breaks, use string interpolation to add them together: