- var_dump: documentation ( source)
<?php
$data = [
0 => 'john',
1 => 'robinson',
2 => '27-08-1980',
3 => 'football',
4 => 'pizza',
];
$template = "{0} {1} birthday {2} <br /> Hobbie : {3} <br /> favorite : {4}";
$string = reg_replace_callback(
'/\{(\d+)\}/',
function ($matches) use ($data) {
var_dump($matches);
return $matches[0];
},
$template
);
echo $string;