Here's a way using a foreach
that iterates through each key of the array, explodes it, and uses the exploded values as keys for a new array:
$result = array();
foreach($array as $key => $value) {
$new_keys = explode('.',$key);
$last_key = array_pop($new_keys); //remove last key from $new_keys
$a =& $result; //make $a and $result be the same variable
foreach($new_keys as $new_key) {
if(!isset($a[$new_key])) {
$a[$new_key] = array();
}
$a =& $a[$new_key]; //reset $a to $a[$new_key]
}
$a[$last_key] = $value; //put $value in the last key
}
print_r($result);
$arr_str = "new['".implode("']['", explode(".", key($arr)))."']=".current($arr); parse_str($arr_str); print_r($new);
See test at eval.in