I've a body of content that is read in and it contains numerous strings like {{some_text}} and what I'm trying to do is to find all these occurances and replace them with another value from an array for example $text["some_text"].
I've tried using preg_replace but not sure how I go about taking the found text between the brackets and use it in the replace value.
$body = "This is a body of {{some_text}} text from a book.";
$text["some_text"] = "really cool";
$parsedBody = preg_replace("\[{].*[}]/U", $text[""], $body);
As you can see I'm trying to get the some_texttext out of the string and use it to call an element from an array, this example is very basic as there $bodyvalue is vastly larger and $texthas a couple hundred elements too it.
preg_replace_callback.preg_replace_callbacknow, for what I need it is overkill to use a templagte library.