RE: [PHP] removing last chr in string
| From: | Maxim Maletsky | Date: | Fri, 27 Oct 2000 03:31:36 +0000 |
| Subject: | RE: [PHP] removing last chr in string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-22256@lists.php.net to get a copy of this message | ||
one way would be
$string = substr(0,rtrim($string,',')-1)
but you could also use regex(a little slower)
$string = ereg_replace(",( )*$", '', $string)
this will remove the comma with one or more whitespaces between it and the
end of the string.
Cheers!
-----Original Message-----
From: Dallas Kropka [mailto:dallask@firstworld.net]
Sent: Friday, October 27, 2000 12:20 PM
To: jasonc@webpipe.net
Cc: PHP LIST
Subject: Re: [PHP] removing last chr in string
Chop ($your_string);
this will remove the whitespace and the newlines...
----- Original Message -----
From: "Jason Cox" <jasonc@webpipe.net>
To: "Rebecca" <rebecca@digitalpulp.com>
Cc: <php-general@lists.php.net>
Sent: Thursday, October 26, 2000 5:32 PM
Subject: RE: [PHP] removing last chr in string
> Try:
>
> $string = substr(0,strrpos($string,',')-1);
>
> Jason
>
> > -----Original Message-----
> > From: Rebecca [mailto:rebecca@digitalpulp.com]
> > Sent: Thursday, October 26, 2000 3:35 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] removing last chr in string
> >
> >
> > is there a quick and easy way to remove the last character in a
> > string if it is not a whitespace, newline, tab, etc?
> > the last character is always a comma - i want to remove the comma.
> >
>
> _______________________________________________________
> Site Design, Hosting, and E-Commerce at www.webpipe.net
>
> --
> 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
>
>
--
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