ecopetition Posted September 9, 2010 Share Posted September 9, 2010 Hey, I have the following two arrays, of which I want to use bits of each from to get another array. Array 1: Array ( [0] => Array ( [shop_id] => 1 [shop_name] => Aldi [shop_district] => 6 ) [1] => Array ( [shop_id] => 2 [shop_name] => Greggs [shop_district] => 6 ) [2] => Array ( [shop_id] => 3 [shop_name] => Tesco [shop_district] => 6 ) [3] => Array ( [shop_id] => 4 [shop_name] => Morrisons [shop_district] => 6 ) [4] => Array ( [shop_id] => 5 [shop_name] => Ryman [shop_district] => 6 ) [5] => Array ( [shop_id] => 6 [shop_name] => Boots [shop_district] => 6 ) [6] => Array ( [shop_id] => 7 [shop_name] => Superdrug [shop_district] => 6 ) [7] => Array ( [shop_id] => 8 [shop_name] => City [shop_district] => 2 ) [8] => Array ( [shop_id] => 9 [shop_name] => Lizard [shop_district] => 6 ) [9] => Array ( [shop_id] => 10 [shop_name] => Asda [shop_district] => 8 ) [10] => Array ( [shop_id] => 11 [shop_name] => Tesco [shop_district] => 2 ) [11] => Array ( [shop_id] => 12 [shop_name] => Tesco [shop_district] => 8 ) ) Array ( [0] => Array ( [shop_id] => 1 [shop_name] => Aldi [shop_district] => 6 ) [1] => Array ( [shop_id] => 2 [shop_name] => Greggs [shop_district] => 6 ) [2] => Array ( [shop_id] => 3 [shop_name] => Tesco [shop_district] => 6 ) [3] => Array ( [shop_id] => 4 [shop_name] => Morrisons [shop_district] => 6 ) [4] => Array ( [shop_id] => 5 [shop_name] => Ryman [shop_district] => 6 ) [5] => Array ( [shop_id] => 6 [shop_name] => Boots [shop_district] => 6 ) [6] => Array ( [shop_id] => 7 [shop_name] => Superdrug [shop_district] => 6 ) [7] => Array ( [shop_id] => 8 [shop_name] => City [shop_district] => 2 ) [8] => Array ( [shop_id] => 9 [shop_name] => Lizard [shop_district] => 6 ) [9] => Array ( [shop_id] => 10 [shop_name] => Asda [shop_district] => 8 ) [10] => Array ( [shop_id] => 11 [shop_name] => Tesco [shop_district] => 2 ) [11] => Array ( [shop_id] => 12 [shop_name] => Tesco [shop_district] => 8 ) ) Array 2: Array ( [0] => Array ( [sUM(item_price)] => 31.23 [item_shop] => 1 ) [1] => Array ( [sUM(item_price)] => 1.65 [item_shop] => 2 ) [2] => Array ( [sUM(item_price)] => 41.23 [item_shop] => 3 ) [3] => Array ( [sUM(item_price)] => 7.98 [item_shop] => 4 ) [4] => Array ( [sUM(item_price)] => 4.49 [item_shop] => 7 ) ) I'd love if anyone could tell me how I can generate an array that will combine bits of these two arrays, so that using the first array I can get a shop_name and shop_district for each item_shop (aka shop_id). Then I want to get an array with entries that look something like this: [0] => Array ( [sUM(item_price)] => 31.23 [shop_name] => Aldi [shop_district] => 6 ) Thanks so much for your help, it means a lot to me. Quote Link to comment https://forums.phpfreaks.com/topic/212923-combining-two-arrays-sort-of/ Share on other sites More sharing options...
pornophobic Posted September 9, 2010 Share Posted September 9, 2010 The example on this page might put you in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/212923-combining-two-arrays-sort-of/#findComment-1109041 Share on other sites More sharing options...
ecopetition Posted September 9, 2010 Author Share Posted September 9, 2010 How do I apply this when the condition is "trapped" within an array? Quote Link to comment https://forums.phpfreaks.com/topic/212923-combining-two-arrays-sort-of/#findComment-1109143 Share on other sites More sharing options...
ecopetition Posted September 9, 2010 Author Share Posted September 9, 2010 Can anybody help? Quote Link to comment https://forums.phpfreaks.com/topic/212923-combining-two-arrays-sort-of/#findComment-1109207 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.