I know we've got some PHP gurus in here. I've got a line of code that is about to get to the hair-pulling stage, so I'm going for a fag and hoping someone else can give me the correct syntax while I calm down...
I'm trying to use a backreference from a pattern match as an array key in a replacement. Something like this:
I've tried $arr['\\1'] and $arr[$1] and various other ways of writing it, and none of them have worked. Anybody?
I'm trying to use a backreference from a pattern match as an array key in a replacement. Something like this:
preg_replace("/(\w.*?)/", $arr['\\1'], $str);
I've tried $arr['\\1'] and $arr[$1] and various other ways of writing it, and none of them have worked. Anybody?