Here's my problem: I dont want to use eval. The script works and you can view it on a web-page if you need to.
---------------------------------------
Code:
<?php
$array = array(
'LEVEL_1' => array(
'LEVEL_2_1' => array(),
'LEVEL_2_2' => array(),
'LEVEL_2_3' => array(),
),
'LEVEL_2' => array(
'LEVEL_2_1' => array(),
'LEVEL_2_2' => array(),
'LEVEL_2_3' => array(),
),
'LEVEL_3' => array(
'LEVEL_3_1' => array(),
'LEVEL_3_2' => array(),
'LEVEL_3_3' => array(),
),
);
$shortcut =& get_array('/LEVEL_2/LEVEL_2_2/', &$array);
$shortcut['TEST'] = 'Value 2';
print('<pre>');
print_r($array);
function get_array ( $path, &$array )
{
$path = explode('/', $path);
array_shift($path);
array_pop($path);
$real_path = eval("return(\$array['" . join("']['", $path) . "']);");
return( $real_path );
}
?>
---------------------------------------