I have two dynamic multidimansional arrays:
[CODE]$arrayInstruments = array(
“instrument1″=>array(“ID”=>”value”,”name”=>”value”,”model”=>value),
“instrument2″=>array(“ID”=>”value”,”name”=>”value”,”model”=>value),
“instrument3″=>array(“ID”=>”value”,”name”=>”Kg”,”model”=>value),
“instrument4″=>array(“ID”=>”value”,”name”=>”value”,”model”=>value),
“instrument5″=>array(“ID”=>”value”,”name”=>”value”,”model”=>value)
);
$arrayStores = array(
“store1″=>array(“storeID”=>”value”,”name”=>”value”,”address”=>”value”),
“store2″=>array(“storeID”=>”value”,”name”=>”value”,”address”=>”value”),
“store3″=>array(“storeID”=>”value”,”name”=>”value”,”address”=>”value”),
“store4″=>array(“storeD”=>”value”,”name”=>”value”,”address”=>”value”),
“store5″=>array(“storeID”=>”value”,”name”=>”value”,”address”=>”value”)
);
I need to make a program that would search through these arrays and return data based on user input(user enters instrument name). This output should be list of instruments and stores where they can be found. User input is stored in simple variable at the program’s start($instrumentName=”some value”).
I got suggestion to make third array, so there can be established relation between these two arrays(it tells program in what store can particular instrument can be found).
So I made this array:
[CODE]$arrayInstrumentsStores = array(
“relation1” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation2” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation3” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation4” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation5” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation6” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation7” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation8” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation9” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation10” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation11” =>array(“instID”=>”value”,”storeID”=>”value”),
“relation12” =>array(“instID”=>”value”,”storeID”=>”value”),);
As you can se, it stores pairs of ID’s (instrument’s ID and store’s ID).
I would appreciate any help.