PHP character filter function removes the last comma (rtrim) from a string_PHP tutorial

WBOY
Release: 2016-07-21 15:12:36
Original
746 people have browsed it

First, let’s explain each one separately,

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

To filter out the key in a string, you can only use str_replace.
Give me an example,

PHP code

Copy code The code is as follows:

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

rtrim example code 2

Copy code The code is as follows:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326706.htmlTechArticleFirst explain separately, trim filters both ends of the string, rtrim filters the tail of the string, =chop() ltrim filter The first part of the string. To filter the keys in the string, you can only use str_replace. For example...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!