- var_dump: documentation ( source)
- array_merge: documentation ( source)
<?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));