Re: preg_replace insert newline

From: Date: Wed, 02 Jun 2010 21:44:38 +0000
Subject: Re: preg_replace insert newline
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-305762@lists.php.net to get a copy of this message
On 06/02/2010 04:28 PM, Sam Smith wrote: > $string = 'text with no newline'; > $pattern = '/(.*)/'; > $replacement = '${1}XX\nNext line'; > $string = preg_replace($pattern, $replacement, $string); > echo $string; > > Outputs: > text with no newlineXX\nNext line > Instead of: > text with no newlineXX > Next line > > How does one insert a newline with preg_replace? > > Thanks http://us.php.net/manual/en/language.types.string.php Pay attention to single and double. -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#305762) next »