Skip to content
Advertisement

PHP – Find multidimensional array search

I have multidimensional array where I need to find attribute name “Gallery” and retrieve value for this…in my test this should be “test_gallery”. All with use of PHP. Just a note, order of data in array may change, order of last array will always stay…attribute_id, name, text.

Structure of this array is as per attached image.

PS: here is twig code that does same and works ok:

JavaScript

Here is php code I was trying to use:

JavaScript

Many thanks

enter image description here

Advertisement

Answer

You can retrieve it using nested loops. Depending on the array archistructure, it can be done quite neatly.

I tested it with this code, written based on your attached image:

JavaScript

I did this to retrieve the group which contains the string that you seek:

JavaScript

test_gallery

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