• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

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
0
ellandrd
Asked:
ellandrd
1 Solution
 
aminerdCommented:
$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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now