Prev: Inserting, storing, outputting dates and selections
Next: Set up MySQL + Apache 2.2.4 on Win XP
From: Sam Smith on 2 Jun 2010 17:28 $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
From: Shawn McKenzie on 2 Jun 2010 17:44 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
|
Pages: 1 Prev: Inserting, storing, outputting dates and selections Next: Set up MySQL + Apache 2.2.4 on Win XP |