/**
* This function will convert explode string key
* into multidimensional array with value
*
* Example
* + ORIGINAL ARRAY
* $array = [
* "main;header;up" => "main_header_up value",
* "main;header;bottom" => "main_header_bottom value",
* "main;bottom" => "main_bottom value",
* "main;footer;right;top" => "main_footer_right_top value"
* ];
* + CONVERTED ARRAY
* $array = [
* "main" => [
* "header" => [
* "up" => "main_header_up value",
* "bottom" => "main_header_bottom value"
* ],
* "bottom" => ["main_bottom value"],
* "footer" => [
* "right" => [
* "top" => "main_footer_right_top value
* ]
* ]
* ]
* ];
*
*@param $array - original array
*
*@return $result - destination array
*/
public function key2key($array)
{
$result = [];
foreach($array as $path => $value) {
$temp =& $result;
foreach(explode('.', $path) as $key) {
$temp =& $temp[$key];
}
$temp = $value;
}
return $result;
}