3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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); print_r($template); ?>
based on fnQgF
Output for 5.4.0 - 7.2.0
Warning: preg_match(): Unknown modifier '\' in /in/DvZql on line 27 array(3) { ["site"]=> string(9) "Smartprix" ["users"]=> array(2) { [10]=> array(2) { ["name"]=> string(6) "Hitesh" ["city"]=> string(5) "Delhi" } [34]=> array(2) { ["name"]=> string(7) "Abhinav" ["city"]=> string(9) "Bharatpur" } } ["location"]=> array(2) { ["address"]=> array(2) { ["pincode"]=> string(6) "110035" ["city"]=> string(5) "Delhi" } ["near"]=> string(19) "Shastri Nagar Metro" } }
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/DvZql on line 2
Process exited with code 255.