September 29, 2013

insert </br> after comma with php

Vektor’s Question:

I array text from custom field “black, grey, white” with this code:

<?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'colors', true); ?>

I want show me like this:

black</br>
grey</br>
white

It’s possible with PHP? Many thanks

Use str_replace():

echo str_replace(",", "<br />", get_post_meta($postid, 'colors', true));
...

Please fill the form - I will response as fast as I can!