3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $config = array( 'test' => array( 'derp' => array( 'example' => true, 'test' => 'derp'), 'herpa' => 'derpa', 'perpa' => 'hurradur')); function flatten($array, $current_path='') { $result = array(); foreach($array as $key => $val) { $path = $current_path . '.' . $key; if (is_array($val)) { $result = array_merge($result, flatten($val, $path)); } else { $result[$path] = $val; } } return $result; } var_dump(flatten($config));
Output for 4.3.0 - 7.1.0
array(4) { [".test.derp.example"]=> bool(true) [".test.derp.test"]=> string(4) "derp" [".test.herpa"]=> string(5) "derpa" [".test.perpa"]=> string(8) "hurradur" }