note 25884 deleted from function.str-replace by philip

From: Date: Wed, 07 Oct 2009 08:07:08 +0000
Subject: note 25884 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161467@lists.php.net to get a copy of this message
Note Submitter: art at zollerwagner dot com ---- 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); ?>

« previous php.notes (#161467) next »