Sounds simple enough, but I'm feeling quite stupid today.
If I have an array like this:
$defined_vars = array(
'{POST_TITLE}' => $item['post']['name'],
'{POST_LINK}' => $item['post']['link'],
'{TOPIC_TITLE}' => $item['topic']['name'],
'{TOPIC_LINK}' => $item['topic']['link'],
'{MEMBERNAME}' => $txt['by'] . ' <strong>' . $item['membername'] . '</strong>',
'{POST_TIME}' => $item['time'],
'{VIEWS}' => $txt['attach_viewed'] . ' ' . $item['file']['downloads'] . ' ' . $txt['attach_times'],
'{FILENAME}' => $item['file']['name'],
'{FILENAME_LINK}' => '<a href="' . $item['file']['href'] . '">' . $item['file']['name'] . '</a>',
'{FILESIZE}' => $item['file']['size'],
'{DIMENSIONS}' => $item['file']['image']['width'] 'x' $item['file']['image']['height'],
);
And a String like this:
$string = '<div class="largetext centertext">{POST_LINK}</div><div class="smalltext centertext">{MEMBERNAME}</div><div class="floatright smalltext dp_paddingright">{POST_TIME}</div><div class="dp_paddingleft smalltext">{VIEWS}</div>';
I need it to be replaced with the values of those keys. Is that possible to do? Perhaps using str_replace() somehow? Are array keys allowed to have curly brackets within them? Would that cause any problems? Also, I need this to replace the $string value for ALL times these are found, cause it is possible to have the same output desired more than 1 time. For example, if {POST_TITLE} is defined twice it should output the value twice exactly where they have used it at within the string.
Thanks