Author: ApPHP Language: php
Description: Remove Last Character from String in PHP Timestamp: 2017-10-03 19:53:07 +0000
View raw paste Reply
  1. <?php
  2. // source: http://www.apphp.com/index.php?snippet=php-remove-last-character-from-string
  3. // method 1 - substr and mb_substr
  4. substr($string, 0, -1);
  5. mb_substr($string, 0, -1);
  6.  
  7. // method 2 - substr_replace
  8. substr_replace($string, '', -1);
  9.  
  10. // method 3 - rtrim
  11. // it trims all specified characters from end of the string
  12. rtrim($string, ".");
  13. ?>
View raw paste Reply