Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

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

0
rgb192
Asked:
rgb192
2 Solutions
 
AriMcCommented:

<?php

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

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

echo myfunc($str);

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

Open in new window

0
 
rgb192Author Commented:
thanks
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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