Re: Look for and Trim Last Character
| From: | Rasmus Lerdorf | Date: | Wed, 24 Jan 2001 23:04:08 +0000 |
| Subject: | Re: Look for and Trim Last Character | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36516@lists.php.net to get a copy of this message | ||
> Hello, I'd like to check for a character at the end of a string, if it
> exists remove it, example:
>
> Looking for - Z
> In string - StringZ
> Result would be - String
>
> -or-
> Looking for - Z
> In string - StringZzz
> Result would be - StringZzz (no change)
if($str{strlen($str)-1}=='Z') $str = substr($str,0,-1);
-Rasmus