Jump to content

[SOLVED] preg_replace prob when replace $pattern with $replace['${1}']


mzhou88

Recommended Posts

$variable["new"]="hi";
$variable["cow"]="wow";
$string="nice to meet you [phpfile=new]";
$pattern='/\[phpfile=(\w+)\]/i';
$replace=$variable["$1"];
preg_replace($pattern,$replace,$string);

 

When I tried this, it gave me an error about $1 not existing. Does anyone know how to solve this? Thanks..

 

- Mike

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.