3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "objectId | 19 location.street | Rue des clochets translations.fr.idTranslation | 4"; $output = []; $lines = explode("\n", $input); foreach ($lines as $line) { $cols = explode("|", $line); $key = trim($cols[0]); $value = trim($cols[1]); $indices = explode('.', $key); $first = array_shift($indices); if (!isset($output[$first])) $output[$first] = []; $target = &$output[$first]; foreach ($indices as $index) { if (!isset($target[$index])) { $target[$index] = []; $target = &$target[$index]; } } $target = $value; } var_dump($output);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["objectId"]=> string(2) "19" ["location"]=> array(1) { ["street"]=> string(16) "Rue des clochets" } ["translations"]=> array(1) { ["fr"]=> array(1) { ["idTranslation"]=> &string(1) "4" } } }

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:
156.08 ms | 406 KiB | 5 Q