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);
Output for git.master, git.master_jit, rfc.property-hooks
stdClass Object ( [Template[URL]] => asdasdda.com [Template[UPC]] => 548454854631… Example [FieldHow to Answer] => 20 ) Warning: Undefined array key 1 in /in/qsKtF on line 13 Array ( [Template] => Array ( [URL] => asdasdda.com [UPC] => 548454854631… Example ) [FieldHow to Answer] => Array ( [] => 20 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.16 ms | 402 KiB | 8 Q