note 102424 modified in function.preg-replace by thiago

From: Date: Mon, 14 Feb 2011 03:01:40 +0000
Subject: note 102424 modified in function.preg-replace by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176965@lists.php.net to get a copy of this message
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". ?> --was-- useful function: 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". http://php.net/manual/en/function.preg-replace.php

« previous php.notes (#176965) next »