ArraySearch

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nera1981
Forum Newbie
Posts: 3
Joined: Fri Sep 16, 2011 5:06 pm

ArraySearch

Post by nera1981 »

I have two arrays:

Code: Select all

    $instrumenti = array( array( ID => 'value',
                 Name => 'value',
                 Model => 'value '
                ),
              array( ID => 'value',
                 Name => 'value',
              Model => ' value'           
          ),
              array(ID => 'value',
                 Name => 'value',
                 Model => 'value '
                ),
          ID => 'value',
                 Name => 'value',
                 Model => 'value '
                ),


                )
             );

    $stores= array( array( ID => 'value',
                 Name => 'value',
                 Adress => 'value '
                ),
              array( ID => 'value',
                 Name => 'value',
              Adress => ' value'           
          ),
              array(ID => 'value',
                 Name => 'value',
                 Adress => 'value '
                ),
          ID => 'value',
                 Name => 'value',
                 Adress => 'value '
                ),


                )
             );
I need to make a loop that will merge this arrays, and then get the requested data(instrument ID, name, model and information about stores where to get them) based on user input (instrument name). I know I should first create one more array that would help merging of first two arrays. This third array should held information about ID's(both instrument's and store's). But I'am not sure how to do this. I would appreciate any help.
greip
Forum Commoner
Posts: 39
Joined: Tue Aug 23, 2011 8:23 am
Location: Oslo, Norway

Re: ArraySearch

Post by greip »

Are all instruments available from all stores?
nera1981
Forum Newbie
Posts: 3
Joined: Fri Sep 16, 2011 5:06 pm

Re: ArraySearch

Post by nera1981 »

greip wrote:Are all instruments available from all stores?
No. That's why there should be created another array first, which would help to merge first two, and this array should store ID's of both each instrument and store. But I 'am not sure how to do this? And after this, loop should be created that would pass through this arrays, merge them and then return data corresponding to user request.
greip
Forum Commoner
Posts: 39
Joined: Tue Aug 23, 2011 8:23 am
Location: Oslo, Norway

Re: ArraySearch

Post by greip »

How is information about which instruments each store has available represented? Provided this information is stored in a suitable way, you don't necessarily need to combine the stores and instruments arrays.
nera1981
Forum Newbie
Posts: 3
Joined: Fri Sep 16, 2011 5:06 pm

Re: ArraySearch

Post by nera1981 »

greip wrote:How is information about which instruments each store has available represented? Provided this information is stored in a suitable way, you don't necessarily need to combine the stores and instruments arrays.
I 'am not sure. What do you mean by "Provided this information is stored in a suitable way, you don't necessarily need to combine the stores and instruments arrays"? Could you show me how?
Post Reply