Jump to content


Photo

rexex


  • Please log in to reply
2 replies to this topic

#1 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 18 April 2006 - 03:55 PM

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

follow me on twitter @PHPsycho

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 18 April 2006 - 04:22 PM

y not use str_replace??

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

Regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 18 April 2006 - 04:25 PM

[!--quoteo(post=366058:date=Apr 18 2006, 11:55 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 18 2006, 11:55 AM) View Post[/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:

$String = preg_replace('|;|', ";\r\n", $String);

i believe it also makes a difference that you use double quotes for the replacement so the escape characters are actually recognized.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users