How can I make a dynamic replacement with a std object? I can't get how to use $1 in this case :( See below.
$lang->custom_name = "Me";
$lang->custom_email = "Me@me";
$html = "hello {{custom_name}} with {{custom_email}} ";
$html = preg_replace("/{{(custom_.*)}}/", $lang->{'$1'} , $html);
Instead of using
preg_replace, usepreg_replace_callbackas it'll make it possible to use any mechanism you want to supply a replacement value.If you want to use this for handling localization values, there are other, always made libraries that handle both the definition files, translate tools, etc. Look into
gettextand friends (and there are probably other modern alternatives in other frameworks).