Jump to content

Archived

This topic is now archived and is closed to further replies.

ToonMariner

rexex

Recommended Posts

Been busy on here today!!!

OK a quicky

I want to replace "; "

with ;(carriage return)

that is a semi-colon and a carriage return (not the words!!!!! ;))

$string = preg_replace('/; /',';\r,$string);

aint working (tried \\r too)

Any help much appreciated

Share this post


Link to post
Share on other sites
y not use str_replace??

$string=str_replace(';',";\r",$string);

Regards
Liam

Share this post


Link to post
Share on other sites
[!--quoteo(post=366058:date=Apr 18 2006, 11:55 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 18 2006, 11:55 AM) [snapback]366058[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Been busy on here today!!!

OK a quicky

I want to replace "; "

with ;(carriage return)

that is a semi-colon and a carriage return (not the words!!!!! ;))

$string = preg_replace('/; /',';\r,$string);

aint working (tried \\r too)

Any help much appreciated
[/quote]

depending on what OS is running on your server, you have to have "\n" instead (*NIX servers), but just to be safe, your best bet is to use "\r\n" for all your carriage returns:

[code]
$String = preg_replace('|;|', ";\r\n", $String);
[/code]

i believe it also makes a difference that you use double quotes for the replacement so the escape characters are actually recognized.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.