I have a variable in PHP that contains a template of a card I use :
$template = '
<div class="card">
<h1>{{CARD_TITLE}}</h1>
{{CARD_IMAGE}}
{{CARD_LINK}}
</div>
';
During a foreach, I would like to replace theses {{CARD_VALUES}}
by these equivalents found in the array.
So I tried:
foreach ($items as $item) {
echo strtr($template, array('{{CARD_TITLE}}' => $item['title']));
echo strtr($template, array('{{CARD_IMAGE}}' => $item['image']));
echo strtr($template, array('{{CARD_LINK}}' => $item['link']));
}
But it doesn't work.
Any ideas why please ?