Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Implode wrap in tags

Tags:

html

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>"; ?> 

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?

like image 594
Liam Avatar asked Mar 26 '12 13:03

Liam


1 Answers

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>"; 
like image 127
Maxim Krizhanovsky Avatar answered Oct 08 '22 16:10

Maxim Krizhanovsky