Re: preg_replace insert newline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux