In PHP, multidimensional array search refers to searching a key=>value in a multilevel nested array. This search can be done either by the iterative or recursive approach.
Recursive Approach: Check if the key exists in a multidimensional array and the value of a key is equal to required one then the result stored in an array and also recur through each element.
Example: Program to search students whose name is “AMIT” in a multidimensional array and print result.
101 - AMIT
202 - AMIT
Iterative Approach: Below implementation is the iterative approach
Example: Program to search students who lives in “Delhi” in a multidimensional array and print result.
BOB - Delhi
AMIT - Delhi
ANMOL - Delhi
TONNY - Delhi
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.