- var_dump: documentation ( source)
- preg_replace_callback: documentation ( source)
<?php
$tokens = [
':rr'=>5,
':tipo'=>'\[A-Z]'
];
$regex = '/#([a-zA-z0-9_]+)(:[a-zA-Z]+)/';
$pattern = '#nombre:tipo';
//echo preg_replace($regex, "(?<$1>".$tokens[(int) ${2}].")", $pattern);
echo preg_replace_callback($regex, function (array $matches) use ($params) {
var_dump($params);
}, $pattern);