Replace fields values in a string
<p>I want to replace fields values that I get from a database query as an array of objects in a string like this:</p>

<pre><code>"My name is {name} and I live in {city}."
</code></pre>

<p>I found the following solution but only works when I replace the values with normal strings, not with an object property:</p>

<pre><code>preg_replace('/\{([a-z]+)\}/', "$row-&gt;\\1", $myString)
</code></pre>

<p>I get this error: <em>Object of class stdClass could not be converted to string</em>.</p>

<p>Why it can't evaluate $row->fielname?</p>

<p>Best regards.</p>
