PHP Implode包装在标签中 [英] PHP Implode wrap in tags

查看:98
本文介绍了PHP Implode包装在标签中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Been trying to google an answer but cant seem to find anything, I have the following...

<?php
    $values =   array_map('trim', get_post_custom_values($key));
    $value  =   implode($values,', ');
    echo "<div class='top-meta-vals'>".apply_filters(" $value\n", $value)."</div>";
?>

我想包装每一个 $ value 在一个span标签中,但我不确定如何......

I want to wrap each and every $value in a span tag but im unsure how...

我试过了,

I tried,

<?php
$value = "<span>".implode($values,', ')."</span>";
?>

没有任何运气,任何人都可以告诉我哪里出错了?

with no luck, can anybody give me an idea of where im going wrong?

推荐答案

通过这种方式,您可以将整个集合包装在一个范围内,您必须将关闭/打开标记添加到内部爆发:

In this way you are wrapping the entire set in one span, you have to add the closing/opening tag to the implode:

$value = "<span>".implode('</span>,<span>', $values)."</span>";

这篇关于PHP Implode包装在标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆