preg_match_all with callback?
You want preg_replace_callback()
.
You would match them with a regex like /=\d+?;/
and then your callback would look like...
function($matches) { return dechex($matches[1]); }
Combined, it gives us...
preg_replace_callback('/=(\d+?);/', function($matches) {
return dechex($matches[1]);
}, $str);
CodePad.
Alternatively, you could use positive lookbehind/forward to match the delimiters and then pass 'dechex'
straight as the callback.