Re: Stripping out last 3 characters??
| From: | Joe Conway | Date: | Fri, 08 Dec 2000 05:56:24 +0000 |
| Subject: | Re: Stripping out last 3 characters?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29288@lists.php.net to get a copy of this message | ||
>
> How do I strip out the last 3 characters of any given string?
>
I'm not sure if you mean remove the last three and retain the original
string, or retain the last three. If you want to do something with the last
three characters of a string here are two options:
$last3 = strrev(substr(strrev($mystring),0,3));
$last3 = substr($mystring,strlen($mystring)-3);
If you want to remove the last three and keep what's left:
$allbutlast3 = substr($mystring,0,strlen($mystring)-3);
Hope this helps,
Joe