note 45140 rejected from function.str-replace by aidan
| From: | aidan@php.net | Date: | Fri, 27 Aug 2004 15:12:51 +0000 |
| Subject: | note 45140 rejected from function.str-replace by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75425@lists.php.net to get a copy of this message | ||
Note Submitter: 4bnormal dot com
----
I find it a filtering and removing from strings a tedious task, so I created the function
str_remove() to help me.
It follows this sytax:
mixed str_remove ( mixed search, mixed subject )
<?php
function str_remove($search, $subject){
str_replace($search, "", $search);
}
$str = "Uno Dos Tres";
$result = str_remove("Dos", $str);
echo $result; // Output: "Uno Tres"
?>
It's quite useful for guestbooks and the like for filtering curse words or DHTML, as
strip_tags() doesn't remove things like 'onClick="javascript:evilStuff()"'
from allowed tags.