replace commas

create a php function to change this

line1,line2,line3,another line,last line

into this
line1
line2
line3
another line
last line

LVL 1
rgb192Asked:
Who is Participating?
 
AriMcConnect With a Mentor Commented:

<?php

function myfunc($str)
{
   return(str_replace(",", "<br>", $str));
}

$str = "line1,line2,line3,another line,last line";

echo myfunc($str);

?>
0
 
Lukasz ChmielewskiConnect With a Mentor Commented:
or
$s = "line1,line2,line3,another line,last line";
$s = implode("<br />",explode(",",$s));

Open in new window

0
 
rgb192Author Commented:
thanks
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.