How to neglect last character of given string in php?
by barkkathulla[ Edit ] 2013-09-26 20:13:42
The following 3 ways are easy to remove substring....
Method 1
$string = "Peacock is a beautiful bird...";
// substr function
echo "substr: " . substr($string, 0, -1);
// mb_substr multibyte version
echo "mb_substr: " . mb_substr($string, 0, -1);
Method 2
$string = "Peacock is a beautiful bird...";
// substr_replace function
echo "substr_replace: " . substr_replace($string ,"",-1);
Method 3
$string = "This is test string..";
// rtrim function
echo "rtrim: " . rtrim($string, ".");