Home » Php » Advance Php Interview Question » Search Elements in Multidimensional Array in Php

Search Elements in Multidimensional Array in Php

Search Elements in Multidimensional Array in Php

In Php there is no one built in function to search any element in Multidimensional Array, we can write own function using recursive procedure.We have create a Simple recursive function to search value in multidimensional array in php.This function returns key of the matched given value if it is in the array.

let Multidimensional array is given below

Example to find element in this array

Method 1:

let write this array in php

$array = array(‘0′ => array(‘id_order_state’ => 19),’1′ => array(‘id_order_state’ => 10),’2′ => array(‘id_order_state’ => 16));

and find element(19,11,16) assign in a veriable

And the Oupot is:

or we can write function below

, , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">