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

yipeiwu_com5年前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)
?>

相关文章

简单的pgsql pdo php操作类实现代码

核心代码: /* *pgsql类 */ class pgdb { public $pdo; public static $PDOInstance; public $conf...

解析PHP对现有搜索引擎的调用

解析PHP对现有搜索引擎的调用

复制代码 代码如下:<?php     $key = $_GET['key'];      ...

解析linux下安装memcacheq(mcq)全过程笔记

memcacheQ是一个单纯的分布式消息队列服务。一,MEMCACHEQ的应用背景Web应用中为什么会需要消息队列?主要原因是由于在高并发环境下,由于来不及同步处理,请求往往会发生堵塞,...

PHP中读取文件的几个方法总结(推荐)

1.fread string fread ( int $handle , int $length ) fread() 从 handle 指向的文件中读取最多 length 个字节。该函数...

PHP实现的一致性哈希算法完整实例

本文实例讲述了PHP实现的一致性哈希算法。分享给大家供大家参考,具体如下: <?php /** * Flexihash - A simple consistent h...