Note parse_str() :
parse_str('set[0][p1]', $AR);
Oh, you want to access the array index ... Here is my trick:
getValue($AR, array('set', 0, 'p1'));
Or if you really should use the original string representation:
parse_str('set[0][p1]', $keys); getValue($AR, $keys);
Disclaimer: I have not tested this, you may need array_keys() somewhere.
And helper function:
function getValue($array, $key, $default = false) { if (is_array($array) === true) { settype($key, 'array'); foreach ($key as $value) { if (array_key_exists($value, $array) === false) { return $default; } $array = $array[$value]; } return $array; } return $default; }
I would not repeat my path in this problem.
source share