3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"Template[URL]":"asdasdda.com","Template[UPC]":"548454854631… Example","FieldHow to Answer":"20"}'; $output = json_decode($json); print_r($output); $newArray = array(); $array = $output; foreach ($array as $key=>$value) { preg_match("/\[(.+)\]/",$key,$match); $newKey = preg_replace("/\[.+\]/","",$key); $newArray[$newKey][$match[1]] = $value; } print_r($newArray);

preferences:
47.73 ms | 402 KiB | 5 Q