Consider this text
$text = 'bla bla bla bla (=abc) bla bla bla bla (=var.var)';
There are 2 special meanings (=abc)and(=var.var)
I need to replace them with values from this array:
$array['abc']='word1';
$array['var.var']='word2';
Mainly inside the pattern (= [az.] +) (Characters az and period).
I need the result: bla bla bla bla *word1* bla bla bla bla *word2*(without *)
I tried it 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 on D: \ net \ test \ index.php on line 9
anon
source
share