note 26774 added to function.strtr

From: Date: Tue, 12 Nov 2002 12:20:21 +0000
Subject: note 26774 added to function.strtr
Groups: php.notes 
Request: Send a blank email to php-notes+get-39375@lists.php.net to get a copy of this message
Suppose you're trying to remove any character not in your set, i've found this very helpfull: function my_remove($string, $my_set, $new=" ", $black="#") { $first = strtr( $string, $my_set, str_repeat($black, strlen($my_set)) ); $second = strtr( $string, $first, str_repeat($new, strlen($first)) ); return $second; }; NOTE that all non-wanted character will be replace with $new, note also that $black must NOT to exist in $my_set. Molok -- http://www.php.net/manual/en/function.strtr.php http://master.php.net/manage/user-notes.php?action=edit+26774 http://master.php.net/manage/user-notes.php?action=delete+26774 http://master.php.net/manage/user-notes.php?action=reject+26774

« previous php.notes (#39375) next »