- print_r: documentation ( source)
- array_merge: documentation ( source)
<?php
function dot($array, $prepend = '')
{
$results = array();
foreach ($array as $key => $value)
{
if (is_array($value))
{
$results = array_merge($results, dot($value, $prepend.$key.'.'));
}
else
{
$results[$prepend.$key] = $value;
}
}
return $results;
}
$array = [
'foo' => [],
'bar' => [
'baz' => 1
]
];
print_r(dot($array));