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
- PHP multidimensional array search by value
- How to check an array is multidimensional or not in PHP ?
- How to merge the duplicate value in multidimensional array in PHP ?
- Convert multidimensional array to XML file in PHP
- Sort a multidimensional array by date element in PHP
- Multidimensional arrays in PHP
- How to search by multiple key => value in PHP array ?
- Perl | Multidimensional Arrays
- Perl | Multidimensional Hashes
- Multidimensional Arrays in Java
- Node | URL.search API
- Binary Search in PHP
- 2-3 Trees | (Search and Insert)
- Indexed Sequential Search
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.