Re: String Manip. - Chop Equivalent
| From: | Terence | Date: | Mon, 24 Nov 2003 00:38:59 +0000 |
| Subject: | Re: String Manip. - Chop Equivalent | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170744@lists.php.net to get a copy of this message | ||
Jed R. Brubaker wrote:
Does PHP have an equivalent to PERL's chop - that is, a way to get rid of the last character in a string? "Hello World" to "Hello Worl" Thanks in advance.this might work, haven't tested it... second param is optional function chop($strSubject, $intWastage = 1) { $strRes = ""; $len = strlen($strSubject); if($intWastage <= $len && $intWastage >= ($len * (-1)))
$strRes = substr($strSubject,0,$len - $intWastage);return $strRes; }