Is there a simple way to update the values of variables that are already present in strings (without using eval or replace functions) with the {$var} syntax?
$id_a=1; $id_b = 2;
echo $str = "The id {$id_a} is related to id {$id_b}\n";
// operations go in here that calculate new values for $id_ variables
$id_a=124214; $id_b=325325;
echo $str = "The id {$id_a} is related to id {$id_b}\n";
You notice that I am assigning the same string twice to $str.
My goal is to assign only once and every time I echo $str if $id_a or $id_b were changed, $str would have the updated values.
If there is a function that achieves this (even if it was not intended for specifically doing this), I haven't found it yet and I would be glad to know about it...
printf().