Link to home
Start Free TrialLog in
Avatar of ellandrd
ellandrdFlag for Ireland

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of aminerd
aminerd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
echo str_replace(',','<br>',$str);
Avatar of Roonaan
I would go with aminerd solution, even when you don't use xhtml at this stage.

-r-
Avatar of ellandrd

ASKER

why aminerd? there is nothing different!
Avatar of aminerd
aminerd

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. :-)