CodeIgniter 字符串辅助函数 - reduce_multiples()

去掉多余的一个紧接着一个重复出现的特殊字符。范例:$string="Fred, Bill,, Joe, Jimmy"; $string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"该函数可以接受如下的形参:reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)第一个形参用于传送你所要去掉重复的字符串。第二个形参用于传送你所要去掉的字符。第三个形参默认为 False。如果为True将会去掉出现在字符串开头或结尾的字符(即使字符不重复也去掉)。范例:[code]$string=“,Fred, Bill, Joe, Jimmy,”;

$string=reduce_multiples($string, ", ", TRUE); //results in “Fred, Bill, Joe, Jimmy”[/code]文章来源:http://cwiki.ossez.com/pages/viewpage.action?pageId=2392225