3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '123.animal=cat 123.name=fred 123.food=fish 345.animal=dog petshop=zoonoria'; $ini = parse_ini_string($data); $result = []; foreach ($ini as $key => $value) { echo $key, ' => ', $value, PHP_EOL; $splitKey = explode('.', $key); $iniPtr = &$result; foreach($splitKey as $subKey) { if (!isset($iniPtr[$subKey])) { $iniPtr[$subKey] = null; } $iniPtr = &$iniPtr[$subKey]; } $iniPtr = $value; unset($iniPtr); } var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
123.animal => cat 123.name => fred 123.food => fish 345.animal => dog petshop => zoonoria array(3) { [123]=> array(3) { ["animal"]=> string(3) "cat" ["name"]=> string(4) "fred" ["food"]=> string(4) "fish" } [345]=> array(1) { ["animal"]=> string(3) "dog" } ["petshop"]=> string(8) "zoonoria" }

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