|
Posted by Kim Andrι Akerψ on 10/20/05 13:09
ThaRez wrote:
> Hello!
> I have a very newbie question. If lets say the variable $text holds
> the value of of a textarea, reciev via "post"; How do I remove the
> possible newlines entered by the user? For example, if the user
> writes the following in the textarea:
>
> "Hello all
> you out there"
>
> How do I get this text (stored in $text) to become:
>
> "Hello all you out there"?
>
> I've tried trim($text) but it doesn't work...
trim() only removes newlines and whitespace from the beginning and end
of a string, not in the middle of it. You could try this:
$text = str_replace(array("\n","\r")," ",$text);
This will take care of both carriage return (CR, "\r") and line feed
(LF, "\n") on one line.
--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Navigation:
[Reply to this message]
|