Created
May 20, 2012 20:53
-
-
Save apphp-snippets/2759496 to your computer and use it in GitHub Desktop.
his is a very common PHP question of HOW TO remove last character from string in PHP. Find below some ways how to delete last character from string in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
// method 1 - substr and mb_substr | |
substr($string, 0, -1); | |
mb_substr($string, 0, -1); | |
// method 2 - substr_replace | |
substr_replace($string, '', -1); | |
// method 3 - rtrim | |
// it trims all specified characters from end of the string | |
rtrim($string, "."); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment