This PHP replace last character in string example using substr
:
$string = substr($string, 0, -1);
Remove last character from string if character is known using rtrim
:
$sourcestr = "Remove the comma from end of this string,";
$string = rtrim($arraynama, ",");
// Output
// Remove the comma from end of this string
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.