- var_dump: documentation ( source)
- phpversion: documentation ( source)
- implode: documentation ( source)
- array_fill: documentation ( source)
<?php
//Enter your code here, enjoy!
$array = array("1" => "PHP code tester Sandbox Online",
"foo" => "bar", 5 , 5 => 89009,
"case" => "Random Stuff",
"PHP Version" => phpversion()
);
function dotnot(array $data = [])
{
$ritit = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data));
$result = array();
foreach ($ritit as $leafValue)
{
$keys = array();
$range = $ritit->getDepth();
;
// for($i=0; $i<$range; $i++)
foreach (array_fill(0, $ritit->getDepth()) as $depth)
{
$keys[] = $ritit->getSubIterator($depth)->key();
}
$result[implode('.', $keys)] = $leafValue;
}
return $result;
}
var_dump(dotnot($array ));