Creating a complex nested array key

I am not aware of anything builtin to php that will allow you to do this. But there a Symfony component called PropertyAccessor with this sort of functionality.

The code would look like:

use Symfony\Component\PropertyAccess\PropertyAccess;

$accessor = PropertyAccess::createPropertyAccessor();

$accessor->setValue($array,'[houses][ocean_view][state]';

Not exactly what you asked for but close.

1 Like