insert br at comma

how can i insert a <br> where a "comma" appears in a string?

my string example: this is, the string, i want, to, break, up

result show look like:

this is
the string
i want
to
break
up

ellandrd
LVL 16
ellandrdAsked:
Who is Participating?
 
aminerdConnect With a Mentor Commented:
$string = str_replace(',', '<br/>', $string);
0
 
dr_dedoCommented:
echo str_replace(',','<br>',$str);
0
 
RoonaanCommented:
I would go with aminerd solution, even when you don't use xhtml at this stage.

-r-
0
 
ellandrdAuthor Commented:
why aminerd? there is nothing different!
0
 
aminerdCommented:
The difference is between <br/> (mine) and <br> (dedo's): one is valid XHTML, the other is not. Possibly not that big of a deal for you, but a difference nonetheless. :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.