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;
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to