more on trimming
| From: | jaskirat | Date: | Sat, 17 Feb 2001 08:16:39 +0000 |
| Subject: | more on trimming | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-40303@lists.php.net to get a copy of this message | ||
Since this thread is running I would like to know the gurus' opinons on the
similar following situation
Suppose there is a variable like this
$var = "This is a variable ";
Now I want to strip off white spaces on the end without losing them in the
middle of the sentence ..
I had figured that there is a no direct way of doing it and some thing like
this
works
$var = trim (ereg_replace(" ","",$var));
the first argument to ereg_replace is "two spaces" so that single spaces
between the words are not removed
then trim to remove any space on the end which may still remain.
But I feel its still not a fool proof solution because there may be two
spaces in between words some where also
which will then be clubbed together.
Any body has a better idea.
Jaskirat
At 09:51 PM 2/16/01 -0500, you wrote:
>> Trim() will in fact only strip whitespace from the beginning or end of
>> the string; if he has \n's anywhere in the middle of the string, trim
>> will do perform the desired operation.
>
>CORRECTION : "trim will not perform the desired operation"
>
><snip>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>