Apologies for the poor title and explanation.
Say I have an array like this:
$myArray = array(
"name" => "Hello",
"description" => "World"
);
and some HTML like this:
<h1>{name}</h1>
<p>{description}</p>
Using PHP's preg_replace function (or something else, I don't mind), would it be possible to replace the {} strings with the value in the array?
<h1>Hello</h1>
<p>World</p>
preg_replace_callback. I'm sure some kind soul will give you codez in a minute.{}, and you never have a{or}in the key, then you only need to scan through the text once building a list of indicies for substring replacements. It's probably due to not really using php, and a habit from other experiences, but i don't like using regex for every possible oportunity - seems overkill. I do like the ouzo-goodies solution below though, which has abstracted away the not so nice expression above.