Posted by Tyno Gendo on 04/07/07 16:22
MS wrote:
> Im sure this must be quite easy to accomplish but I can not find the
> function/way to do it.
>
> MySQL Database field is saved as....
>
> "this is the text
>
> and has line breaks
>
> like this"
>
> Now I want to concat each line into a variable like this.
>
> "this is the text and has line breaks like this"
>
> I have tried trim() which supposedly takes out whitespace but its not
> working as I expect.
>
> What do I have to do?
>
> Thanks
>
>
<?php
$text="This is a line\r\nwith carriage\r\nreturns\r\nin it";
echo "<pre>$text</pre>";
$nocr=preg_replace("/\r\n/"," ",$text);
echo "<pre>$nocr</pre>";
?>
[Back to original message]
|