#24061 [Opn->Bgs]: dynamic variables in preg_replace
| From: | sniper@php.net | Date: | Fri, 06 Jun 2003 19:40:51 +0000 |
| Subject: | #24061 [Opn->Bgs]: dynamic variables in preg_replace | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-41385@lists.php.net to get a copy of this message | ||
ID: 24061
Updated by: sniper@php.net
Reported By: c dot luxig at lmcsoft dot com
-Status: Open
+Status: Bogus
-Bug Type: *Regular Expressions
+Bug Type: PCRE related
Operating System: Win XP
PHP Version: 4.3.2
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Ask support questions elsewhere, thank you.
Previous Comments:
------------------------------------------------------------------------
[2003-06-06 10:00:07] c dot luxig at lmcsoft dot com
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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24061&edit=1