- array_reduce: documentation ( source)
- preg_split: documentation ( source)
<?php
$a = array();
$arrayKey = '[0][1]';
$a[0][1] = "two levels deep";
$vars = function($str) use ($vars)
{
$c = function($v, $w) {return $w ? $v[$w] : $v;};
return array_reduce(preg_split('~\[\'|\'\]~', $str), $c, $vars);
};
echo $vars('[0][1]');