note 81705 deleted from function.str-replace by nlopess
| From: | nlopess@php.net | Date: | Mon, 10 Mar 2008 17:13:15 +0000 |
| Subject: | note 81705 deleted from function.str-replace by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-136907@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at freedownloads32 dot com
----
Use this function to remove unwanted characters.
Here is how it works:
1. it replaces all the unwanted characters with spaces
2. than it replaces multiple spaces with one space
Now you have a clean $subject
function str_replace_all($search,$replace,$subject) {
for($x=0;$x<strlen($search);$x++){
$search1 = substr($search,$x,1);
while(strpos($subject,$search1)!==false) {
$subject = ereg_replace(' +', ' ',
str_replace($search1,$replace,$subject));
}
}
return $subject;
}
use:
str_replace_all('/()[]-+&!?#:_', ' ', '$subject')
John Lande
http://www.freedownloads32.com