note 25884 added to function.str-replace
| From: | art at zollerwagner dot com | Date: | Wed, 09 Oct 2002 20:26:12 +0000 |
| Subject: | note 25884 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37866@lists.php.net to get a copy of this message | ||
To use one or two arrays in str_replace,
this appears to be the correct format:
str_replace(array('1st_current_needle_element', '2nd, '3rd'),
array('1st_new_needle_element', '2nd', '3rd'), $haystack)
Example of a single array, which simply removes the characters in the first array:
$text=str_replace(array('<', '>', '\\', '/',
'='), "", $text);
This will delete the chars: < > \ / =
It could also be done by first defining the array(s), like this:
$targetChars=array('<', '>', '\\', '/',
'=');
$text=str_replace($targetChars, "", $text);
--
http://www.php.net/manual/en/function.str-replace.php
http://master.php.net/manage/user-notes.php?action=edit+25884
http://master.php.net/manage/user-notes.php?action=delete+25884
http://master.php.net/manage/user-notes.php?action=reject+25884