note 45424 added to function.preg-replace

From: Date: Mon, 06 Sep 2004 21:10:20 +0000
Subject: note 45424 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-76115@lists.php.net to get a copy of this message
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 ); ?> ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45424 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45424&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45424&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76115) next »