PHP字符过滤函数去除字符串最后一个逗号(rtrim)

yipeiwu_com6年前PHP代码库

首先分别解释下,

trim过滤字符串两端,
rtrim过滤字符串尾部,=chop()
ltrim过滤字符串首部.

过滤字符串中键的咚咚就只能用str_replace咯.
举个例子说明下,

PHP代码

复制代码 代码如下:

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

rtrim实例代码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)
?>

相关文章

php 判断页面或图片是否经过gzip压缩的方法

使用php判断页面或图片是否经过gzip压缩方法 1.使用get_headers 页面内容 <?php ob_start('ob_gzhandler'); // 开启...

php 结果集的分页实现代码

复制代码 代码如下:<?php @mysql_connect("localhost", "root","1981427") //连接数据库服务器 or die("数据库服务器连接失...

PHP实现将浏览历史页面网址保存到cookie的方法

本文实例讲述了PHP实现将浏览历史页面网址保存到cookie的方法。分享给大家供大家参考。具体如下: 将浏览历史页面网址保存到cookie,大致的思路如下面的代码,与实际应用有些差别。...

php IP及IP段进行访问限制的代码

192.168.1.1 单个IP 192.168.1.* 这样代理 192.168.1.1-192.168.1-255 192.158.1.2-20 这样是代表192.158.1.2-1...

解析在apache里面给php写虚拟目录的详细方法

步骤1.首先打开AppServ\Apache2.2\conf里面的httpd.conf文件。在里面找到:LoadModule rewrite_module modules/mod_rew...