Re: How to remove only the last character?

From: Date: Sat, 08 Feb 2003 13:32:50 +0000
Subject: Re: How to remove only the last character?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-134865@lists.php.net to get a copy of this message
Hiya, Try this, *probably* more efficient but I don't know for sure. <? $string = 'testing 1 2 3 testing'; echo $string . "\n"; $string[strlen($string)-1] = "\0"; echo $string . "\n"; ?> Regards, Ian Packer ----- Original Message ----- From: "Douglas Douglas" <replaceafill@yahoo.com> To: <php-general@lists.php.net> Sent: Saturday, February 08, 2003 1:21 PM Subject: [PHP] How to remove only the last character? > Good day. > > Is there any PHP function that removes only the last > character of a string and returns the new string? > > I'm looking in the manual and I can't find anything. > > Until now I'm doing this: > > $var=substr($var,0,strlen($var)-1) > > Is this the most efficient way? > > Thanks. > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#134865) next »