note 46580 deleted from function.preg-replace by aidan

From: Date: Sun, 05 Dec 2004 15:17:10 +0000
Subject: note 46580 deleted from function.preg-replace by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81403@lists.php.net to get a copy of this message
Note Submitter: dinah ---- this example was incorrectly provided by a user: $string="My name is [0]"; $names=array("Bill","Bob","Joe"); $string = preg_replace("/\[(\d+)\]/",$names[(int) ${1}],$string); echo $string; output should be "My name is Bill" output works with the above case only. $string = '[1]' does NOT output Bob. these also do NOT work: $names[${1}] $names[\${1}] $names[$1] $names[\$1] $names[\\$1] only these seems to work: $names[\1] $names[\\1]

« previous php.notes (#81403) next »