Skip to content
Advertisement

PHP: Use Variable as Multiple Keys in Multi-Dimensional-Array

In a normal array you can select this way

JavaScript

How about in a multidimensional?

JavaScript

What’s the proper way to go about this?

Advertisement

Answer

i think this solution is good.

note that you have to wrap all keys with “[” and “]”.

JavaScript

Learn more about eval() function

if you also want to check if the value is defined or not then you can use this function

JavaScript

Giving a better name to that function will be appreciated ^^

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement