PHP: Remove Last Character from String – substr / substr_replace / rtrim - Comment Page: 1

This is a very common PHP question, how to remove last character from string in PHP? So here are three ways how to delete last character from string in PHP. [inttf_post_ad1] Method 1 - PHP: Remove Last Character from String using substr and mb_substr substr and mb_substr commands usage substr($string, 0, -1); mb_substr($string, 0, -1); substr and mb_substr example: $string = "This is test string.."; echo $string . "\n"; // substr function echo "substr: " . substr($string, 0, -1); echo "\n"; // mb_substr multibyte version echo "mb_substr: " . mb_substr($string, 0, -1); echo "\n"; Example output: This is test string.. This is test...