Consider this text
$text = 'bla bla bla bla (=abc) bla bla bla bla (=var.var)';
There are 2 special values there (=abc)
and (=var.var)
I need to replace them with values from this array:
$array['abc']='word1';
$array['var.var']='word2';
Basically inside the pattern is (=[a-z.]+) (chars a-z and dot).
Result i need: bla bla bla bla *word1* bla bla bla bla *word2*
(without *)
I tried this with no luck
preg_replace('/\(=([a-z\.]+)\)/',"$array['\\1']",$text);
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\net\test\index.php on line 9