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 ?
- Convert multidimensional array to XML file in PHP
- Sort a multidimensional array by date element in PHP
- Multidimensional arrays in PHP
- Perl | Multidimensional Hashes
- Multidimensional Arrays in Java
- How to search by multiple key => value in PHP array ?
- Binary Search in PHP
- Node | URL.search API
- Node | urlObject.search API
- 2-3 Trees | (Search and Insert)
- Indexed Sequential Search
- Mobile Search Engine Optimization (SEO)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.