Issue
I am hacking together a theme for Wordpress and I am using the following code to pull out data from a custom field with several values:
$mykey_values = get_post_custom_values('services');
foreach ( $mykey_values as $key => $value ) {
echo "<span>$value, </span>";
}
I use a comma to separate the results, but I don't want a comma after the last result. How do I get around this?
Solution
Best way is with implode:
echo('<span>' . implode('</span>, <span>', $mykey_values) . '</span>');
Answered By - AlexV
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.