[Solved] Multiple array keys from array


$array = array();
$current =& $array;
$keys = $array('one', 'two', 'three');
$value="text";

foreach (array_slice($keys, 0, -1) as $k) {
    $current[$k] = array();
    $current = & $current[$k];
}
$current[$keys[count($keys)-1]] = $value;

Using a reference for $current allows it modify the nested arrays in place.

1

solved Multiple array keys from array