I want to dynamically replace placeholder variables in a string.
str_replace("\$", $data["Whatever follows the \$], $variable);
\$ signifies a placeholder variable, \$ID for example.
The data I want it to be replace with is in an array. $\ID should be replaced with $data['ID'].
For example, if I have a string that says "The ID is \$ID and name is \$name". I want to replace both the \$ID and \$name with the relevant data in my $data object. $\ID would be $data['ID'] and so on.
This needs to be dynamic. I don't want to hard code it to replace \$ID with $data['ID']. The key used to get the data in $data should be equal to what follows the \$.
I'm having trouble figuring out not only how to do this dynamically like I have talked about, but to do it for every \$ in a string.