note 31630 rejected from function.preg-replace by spic

From: Date: Mon, 28 Apr 2003 16:42:39 +0000
Subject: note 31630 rejected from function.preg-replace by spic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47217@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)

« previous php.notes (#47217) next »