I want to replace fields values that I get from a database query as an array of objects in a string like this:
"My name is {name} and I live in {city}."
I found the following solution but only works when I replace the values with normal strings, not with an object property:
preg_replace('/\{([a-z]+)\}/', "$row->\\1", $myString)
I get this error: Object of class stdClass could not be converted to string.
Why it can't evaluate $row->fielname?
Best regards.