Page 1 of 1

ArraySearch

Posted: Fri Sep 16, 2011 5:11 pm
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.

Re: ArraySearch

Posted: Fri Sep 16, 2011 5:18 pm
by greip
Are all instruments available from all stores?

Re: ArraySearch

Posted: Sat Sep 17, 2011 2:18 am
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.

Re: ArraySearch

Posted: Sat Sep 17, 2011 4:34 am
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.

Re: ArraySearch

Posted: Sat Sep 17, 2011 4:16 pm
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?