How can I convert {$game.name.fullname} to $game[\'name\'][\'fullname\'] using regex.
thanks
If you are asking how to replace {$game.name.fullname} with the value of $game['name']['fullname'], my first suggestion would be not to allow the template to include any old variable (you don't want access to vars like $secret_password), but make an array of values that can be included.
Take a look at this:
array(
'name' => array(
'fullname' => 'test'
)
)
);
$matches = array();
preg_match('/{\$([^.]+)\.([^.]+)\.([^}]+)}/', '{$game.name.fullname}', $matches);
var_dump($matches);
echo '
';
echo $matches[1] .'
';
echo $matches[2] .'
';
echo $matches[3] .'
';
echo '
';
echo $games[$matches[1]][$matches[2]][$matches[3]];
?>