How to search multiple items in a multidimentional array ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mohan lal
    New Member
    • Mar 2011
    • 25

    How to search multiple items in a multidimentional array ?

    Hi All,

    I have an array like
    Code:
    Array
    (
        [0] => Array
            (
                [first] => Array
                    (
                        [name] => test
                        [email] => test@mail.com
                        [address] => test
                     )
    
            )
    
        [1] => Array
            (
                [second] => Array
                    (
                        [name] => test1
                        [email] => test1@mail.com
                        [address] => test1
                     )
    
            )
    
    )
    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
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    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

    Comment

    • mohan lal
      New Member
      • Mar 2011
      • 25

      #3
      Hi dlite922,

      Thanks for your reply. I have found a solution to multidimensiona l array searching and working its fine. Anyway thank you..

      Comment

      Working...