By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

How to search multiple items in a multidimentional array ?

P: 25
Hi All,

I have an array like
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [0] => Array
  4.         (
  5.             [first] => Array
  6.                 (
  7.                     [name] => test
  8.                     [email] => test@mail.com
  9.                     [address] => test
  10.                  )
  11.  
  12.         )
  13.  
  14.     [1] => Array
  15.         (
  16.             [second] => Array
  17.                 (
  18.                     [name] => test1
  19.                     [email] => test1@mail.com
  20.                     [address] => test1
  21.                  )
  22.  
  23.         )
  24.  
I want to search multiple values in that array, For eg: if we give name as "test" and address as "test" then the search should check both the condition name and address like "test" and then print the result.
How can create a search like this ? If anyone knows please help me thanks in advance
Mar 13 '12 #1
Share this Question
Share on Google+
2 Replies


dlite922
Expert 100+
P: 1,584
Are you searching for key-> value pairs? or search for a keyword no matter if it's a key or a value. If the former, you first take the key and search for keys in the array matching that, as soon as you have a match, you compare its value to your value, if it's a match you return it. (or continue if you want to find all instance of it)

Tackle the code yourself and let us know where you get stuck,

Dan
Mar 16 '12 #2

P: 25
Hi dlite922,

Thanks for your reply. I have found a solution to multidimensional array searching and working its fine. Anyway thank you..
Mar 17 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.