我想通過一個共同的值合併兩個數組(它們來自mysql的查詢),但很遺憾,直到現在沒有運氣。按值合併兩個多維數組
所以基本上,我有兩個單獨的數組,你可以看到下面,第一個被稱爲$第一步,第二個$第二步
Array
(
[0] => Array
(
[0] => 4
[inventory_id] => 4
[1] => 13
[box] => 13
[2] => 4
[wine_id] =>
[3] => 34
[quantity] => 34
[4] => [email protected]
[email] => [email protected]
)
[1] => Array
(
[0] => 9
[inventory_id] => 9
[1] => 0
[box] => 0
[2] => 17672
[wine_id] =>
[3] => 538
[quantity] => 538
[4] => [email protected]
[email] => [email protected]
)
)
Array
(
[0] => Array
(
[0] => 4
[wine_id] => 4
[1] => Ajaccio (CORSE)
[villesetregion] => Ajaccio (CORSE)
[2] => Ajaccio
[villes] => Ajaccio
[3] => (CORSE)
[regions] => (CORSE)
[4] => Clos d'Alzeto 2008
[nometannee] => Clos d'Alzeto 2008
[5] => Clos d'Alzeto
[nom] => Clos d'Alzeto
[6] => 2008
[annee] => 2008
[7] => 8 à 11 €
[prix] => 8 à 11 €
[8] => Guide 2010
[anneeduguide] => Guide 2010
[9] => 2
[etoile] => 2
)
[1] => Array
(
[0] => 17642
[wine_id] => 17642
[1] => Pauillac (BORDELAIS)
[villesetregion] => Pauillac (BORDELAIS)
[2] => Pauillac
[villes] => Pauillac
[3] => (BORDELAIS)
[regions] => (BORDELAIS)
[4] => Chateau Latour 2007
[nometannee] => Chateau Latour 2007
[5] => Chateau Latour
[nom] => Chateau Latour
[6] => 2007
[annee] => 2007
[7] => 75 à 100 €
[prix] => 75 à 100 €
[8] => Guide 2011
[anneeduguide] => Guide 2011
[9] => 2
[etoile] => 2
)
)
在MySQL查詢有以下幾種:
$step1 :
$query2 = "SELECT* FROM `inventory_users` WHERE email='".$email_user."'";
$step2 :
$query3 = "SELECT * FROM `vins_tbl` WHERE wine_id IN (".implode(',', $wine).")";
爲inventory_users數據庫結構是:
1 inventory_id bigint(20)
2 box int(11)
3 wine_id int(11)
4 quantity int(11)
5 email text latin1_swedish_ci
和vins_tb:
1 wine_id int(5) Oui NULL
2 villesetregion varchar(65) utf8_general_ci
3 villes varchar(50) utf8_general_ci
4 regions varchar(30) utf8_general_ci
5 nometannee varchar(105) utf8_general_ci
6 nom varchar(100) utf8_general_ci
7 annee varchar(4) utf8_general_ci
8 prix varchar(13) utf8_general_ci
9 anneeduguide varchar(10) utf8_general_ci
10 etoile varchar(2) utf8_general_ci Oui NULL
,我想這兩個數組由wine_id鍵合併,怎麼能做到呢?
謝謝你的幫助!
1)這些數組來自MySQL查詢? 2)在你的第一個數組中'wine_id'顯示爲空。 – fusion3k
mmm ...並且我想要一個「Chateau Latour」的_verre_ ... – fusion3k
是的,他們來自mysql查詢 – BrunoGG