I am trying to replace from a text string with values from an associative array.
Everything I have tried so far seems not to work. Any ideas?
Here is an example:
$res = (a row from a database)
$msg = (some text from a user where --varname- should be replaced by the value in the $res associative array)
this gave me an error:
$msg=ereg_replace("--([-]*)-","$res[\1]",$msg);
as did this
$msg=ereg_replace("--([-]*)-","$res[\"\1\"]",$msg);
and this did not reutnr the value (but didnt error)
$msg=ereg_replace("--([-]*)-",$res["\1"],$msg);