preg_replace insert newline

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

 



$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

-- 
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