- preg_match_all: documentation ( source)
- str_replace: documentation ( source)
<?php
$string = "{download='text for button'} HAHA! {download='test'}";
preg_match_all("/{download='(.*?)'}/", $string, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$string = str_replace("{download='" . $val[1] . "'}", "<a class=\"button\">" . $val[1] . "</a>", $string);
}
echo $string;