note 25884 modified in function.str-replace by aidan
| From: | aidan@php.net | Date: | Sun, 27 Jun 2004 13:48:48 +0000 |
| Subject: | note 25884 modified in function.str-replace by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71896@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:
<?php
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:
<?php
$text=str_replace(array('<', '>', '\\', '/',
'='), "", $text);
?>
This will delete the chars: < > \ / =
It could also be done by first defining the array(s), like this:
<?php
$targetChars=array('<', '>', '\\', '/',
'=');
$text=str_replace($targetChars, "", $text);
?>
--was--
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://php.net/manual/en/function.str-replace.php