note 31630 added to function.preg-replace

From: Date: Mon, 28 Apr 2003 16:12:15 +0000
Subject: note 31630 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-47215@lists.php.net to get a copy of this message
I've got a String which includes words like "Field0", "Field2", "Field3" etc. Now I want to replace these words with values which are stored in an array. The last digit of the words to be replaced should be the index for the array. Bit instead of replacing the "FieldX"-words with the array-values, they are replaced with "$array[0]", "$array[1]" etc. What's wrong? Here's the code which I user: preg_replace ("/Field([0-9]+)/",'$array[$1]',$template) greetz, Sascha. (wannabe-php-checker) -- http://www.php.net/manual/en/function.preg-replace.php http://master.php.net/manage/user-notes.php?action=edit+31630 http://master.php.net/manage/user-notes.php?action=delete+31630 http://master.php.net/manage/user-notes.php?action=reject+31630

« previous php.notes (#47215) next »