Im trying to use a regular expression backreference to reference a hash key.
Here's an example of the non working code so you can see what I'm trying to achieve (I hope!):
$str="String of text containing item1 and item2";
$x['item1']="Item 1";
$x['item2']="Item 2";
$str=preg_replace("/item1/","$x[\${1}1]",$str);
print $str;
I want to get the result "String of text containing Item 1 and Item 2" - it must use the backreference to get the result out of the hash. Anyone got any ideas?
Thanks in advance,
Matt.