|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-06-06 14:40 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
Dynamic variables were not used in preg_replace(). I want searching html code for the tag "<usr my_var>" and want to replace this tag by the HTTP_POST or HTTP_GET var "my_var", but it doesn't work. Here is my regexp: $modified = '[...]<usr my_var>[...]'; $my_var = 'content'; $modified = preg_replace("/<usr\s+?(.*?)\s*?>/ims", ${"$1"}, $modified, -1); Output: [...][...] (replaced by empty string) This expression match to <usr my_var> and if i do the following preg_replace works correct: $modified = preg_replace("/<usr\s+?(.*?)\s*?>/ims", "$1", $modified, -1); Output: [...]my_var[...] And this also doesn't work: $modified = preg_replace("/<usr\s+?(.*?)\s*?>/ims", ${$my_var}, $modified, -1); Output: [...][...] (replaced by empty string) This is the problem.