- array_merge_recursive: documentation ( source)
- print_r: documentation ( source)
- end: documentation ( source)
- explode: documentation ( source)
- prev: documentation ( source)
<?php
$files=array("index.md","storage_index.md","storage_one.md");
$master_array=array();
foreach($files as $file)
{
$file=explode("_",$file);
$cache=end($file);
while($level=prev($file))
{
$cache=array($level=>$cache);
}
$master_array=array_merge_recursive($master_array,$cache);
}
print_r($master_array);