note 23519 deleted from function.preg-replace by sander

From: Date: Sat, 15 Feb 2003 15:21:39 +0000
Subject: note 23519 deleted from function.preg-replace by sander
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-43980@lists.php.net to get a copy of this message
In response to cbakerATcbakerDOTorg: > It would be nice if $string = > preg_replace("/\[\[(\w+)\]\]/", > $args["$1"], $string); worked but it don't. You can do just that using the 'e' modifier: <?php $string = 'asdf[[foo]]asdf[[bar]]asdf'; $args = array( 'foo' => 'BAR', 'bar' => 'PACO' ); $string = preg_replace('#\[\[(\w+)\]\]#e', '$args["$1"]', $string); ?>

« previous php.notes (#43980) next »