PHP

The PHP character filter function removes the last comma of the string of rtrim


First of all,

trim filters both ends of the string, rtrim filter string tail,=chop() ltrim filters string headers.

Filter the keys in the string with str_replace. So for example,

PHP code

$str = '123,333,234,';
echo rtrim($str, ',');

rtrim instance code 2

<?php
$text = "\t\tThese are a few words :) ...  ";
$trimmed = rtrim($text);
// $trimmed = "\t\tThese are a few words :) ..."
$trimmed = rtrim($text, " \t.");
// $trimmed = "\t\tThese are a few words :)"
$clean = rtrim($binary, "\x00..\x1F");
// trim the ASCII control characters at the end of $binary
// (from 0 to 31 inclusive)
?>