3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = array( 'test' => array( 'derp' => array( 'example' => true, 'test' => 'derp'), 'herpa' => 'derpa', 'perpa' => 'hurradur')); function flatten($array, $current_path='test') { $result = array(); foreach($array as $key => $val) { $path = $current_path . '.' . $key; if (is_array($val)) { $result[$path] = $val; $result = array_merge($result, flatten($val, $path)); } else { $result[$path] = $val; } } return $result; } var_dump(flatten($config));
Output for git.master, git.master_jit, rfc.property-hooks
array(6) { ["test.test"]=> array(3) { ["derp"]=> array(2) { ["example"]=> bool(true) ["test"]=> string(4) "derp" } ["herpa"]=> string(5) "derpa" ["perpa"]=> string(8) "hurradur" } ["test.test.derp"]=> array(2) { ["example"]=> bool(true) ["test"]=> string(4) "derp" } ["test.test.derp.example"]=> bool(true) ["test.test.derp.test"]=> string(4) "derp" ["test.test.herpa"]=> string(5) "derpa" ["test.test.perpa"]=> string(8) "hurradur" }

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.36 ms | 402 KiB | 8 Q