note 102424 deleted from function.preg-replace by danbrown
| From: | danbrown@php.net | Date: | Mon, 14 Feb 2011 03:30:54 +0000 |
| Subject: | note 102424 deleted from function.preg-replace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176967@lists.php.net to get a copy of this message | ||
Note Submitter: Shawn Dellysse
----
useful function:
<?php
function preg_replace_assoc($assoc, $subject) {
return preg_replace(array_keys($assoc), array_values($assoc), $subject);
}
//example:
$terms = array(
'/cat/' => 'dog',
'/meow/' => 'bark'
);
preg_replace_assoc($terms, 'The cat goes "meow".'); //The dog goes
"bark".
?>