note 81985 deleted from function.str-replace by felipe

From: Date: Sun, 23 Mar 2008 03:19:53 +0000
Subject: note 81985 deleted from function.str-replace by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137339@lists.php.net to get a copy of this message
Note Submitter: jaimthorn at yahoo dot com ---- If all you want to do is remove characters from a string, then this solution is about 7 times faster: /** * Removes certain characters from a string. * * @param string $string the string to be stripped. * @param string $chars a string containing all the characters to be removed from $string. May be empty. * @return string the original $string with the characters from $chars removed. */ function RemoveChars($string, $chars) { return isset($chars{0}) ? str_replace($chars{0}, "", strtr($string, $chars, str_pad($chars{0}, strlen($chars), $chars{0}))) : $string; }

« previous php.notes (#137339) next »