<?php
$options = [
"site" => "Smartprix",
"users" => [
10 => [
"name" => "Hitesh",
"city" => "Delhi"
],
34 => [
"name" => "Abhinav",
"city" => "Bharatpur"
],
],
"location" => [
"address" => [
"pincode" => "110035",
"city" => "Delhi",
],
"near" => "Shastri Nagar Metro",
],
];
$template = "{{=site}} is located at pincode {{=location.address.pincode}} near
{{=location.near}}. Users of {{=site}} are: {{@users}} User ID: {{=_key}}, name: {{=_val.name}},
city: {{=_val.city}}. {{/@users}}";
function render($string, $array)
{
preg_match("/\{{=(.*/\.?)}}/",$string,$array);
var_dump($array); die;
}
echo render($template, $options);
?>
preferences:
45.86 ms | 402 KiB | 5 Q