I have this little function running at my wordpress site. But I need to add a bit of data to it. Hope I can get help.
Function array_to_comma($data)
{
if (is_array($data) and count($data) > 0)
{
$data = implode(', ', $data);
return $data;
}
}
Which outputs this:
Some Data, Some Data, Some Data
But I want to add some html code to it, a span, but I do not know how. So that it would appear like this in the source code of a rendered page. I see that it already adds a comma, but I cannot figure out to get to add more data then just the comma to appear at start and end. like this:
<span special="codes">Some Data</span>, <span special="codes">Some Data</span>, <span special="codes">Some Data</span>
Thank you in anticipation of a great help!. I am a php noob :)
EDIT: I have successfully used this code below. from the answer from elclanrs.
function array_to_comma($data)
{
if (is_array($data) and count($data) > 0) {
$data = '<span special="code">'
. implode('</span>,<span special="code">', $data)
.'</span>';
return $data;
}
}