$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

Reply via email to