The PHP character filter function removes the last comma of the string, which is easier to solve with the built-in functions of php.
The PHP character filter function removes the last comma of the string, which is easier to solve with the built-in functions of php.
First, explain separately,
Trim filters both ends of a string,
Rtrim filters the tail of the string, = chop ()
Ltrim filters the string header.
You can only use str_replace to filter the middle keys in a string.
For example,
PHP code
The Code is as follows:
$ Str = '1970 ,';
Echo rtrim ($ str ,',');
Rtrim instance Code 2
The Code is as follows:
$ 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 random SIVE)
?>