note 45424 deleted from function.preg-replace by aidan

From: Date: Tue, 07 Dec 2004 03:10:48 +0000
Subject: note 45424 deleted from function.preg-replace by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81465@lists.php.net to get a copy of this message
Note Submitter: Jinx ---- In addition to daniil at nycfoto dot com's entry way back in December 2003: To replace a string like "Dear [name]" with the string in $assoc["name"] use: preg_replace("/\\[(.*?)\\]/e", "\\$assoc['\\\\1']", $str ); example: <?php $str="[some_tag] Cheese [another_tag]"; $assoc['some_tag'] = "I Like"; $assoc['another_tag'] = "With Fries"; echo preg_replace("/\\[(.*?)\\]/e", "\\$assoc['\\\\1']", $str ); ?>

« previous php.notes (#81465) next »