note 55929 added to function.str-replace

From: Date: Thu, 18 Aug 2005 04:46:08 +0000
Subject: note 55929 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-93818@lists.php.net to get a copy of this message
This function recursively replaces multiple instances of the same character, taking it down to a maximum of one. If you have say, a list of tags like (with a arbitrary number of spaces where you want only one): $tags = "php function string cleaning"; r_str_replace(" "," ",$tags); will return a version with only one space between words, ie: "php function string cleaning". function r_str_replace($original, $replace, $string) { $output = str_replace($original, $replace, $string, $count); if ($count == 0) return $output; $output = r_str_replace ($original, $replace ,$output); return $output; } ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55929 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55929&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55929&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55929&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55929&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55929&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55929&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55929&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93818) next »