mzhou88 Posted February 24, 2007 Share Posted February 24, 2007 $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 Link to comment https://forums.phpfreaks.com/topic/39908-solved-preg_replace-prob-when-replace-pattern-with-replace1/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.