You can use this function to set a nested value within an array:
function set_nested_value(array &$array, $index, $value)
{
$node = &$array;
foreach (explode('.', $index) as $path) {
$node = &$node[$path];
}
$node = $value;
}
$a = array();
set_nested_value($a, '1.1.1', 'A');
print_r($a);
Output:
Array
(
[1] => Array
(
[1] => Array
(
[1] => hello
)
)
)