Solved

replace commas

Posted on 2011-02-24
3
259 Views
Last Modified: 2012-05-11
create a php function to change this

line1,line2,line3,another line,last line

into this
line1
line2
line3
another line
last line

0
Comment
Question by:rgb192
3 Comments
 
LVL 9

Accepted Solution

by:
AriMc earned 250 total points
ID: 34975601

<?php

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

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

echo myfunc($str);

?>
0
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 250 total points
ID: 34977372
or
$s = "line1,line2,line3,another line,last line";
$s = implode("<br />",explode(",",$s));

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 34982520
thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now