2017-03-09 113 views
1

我有4個陣列與每個10個元素:合併多個陣列值到一個數組值

$vidtype = Array ([0] => Array ([0] => Sales [1] => Sales [2] => Sales [3] => Sales [4] => Sales [5] => Sales [6] => Sales [7] => Sales [8] => Sales [9] => Sales 

$vidcategory = Array ([0] => Array ([0] => comfortsystemen [1] => multimediasystemen [2] => assistentiesystemen [3] => multimediasystemen [4] => productfilms [5] => assistentiesystemen [6] => multimediasystemen [7] => productfilms [8] => productfilms [9] => productfilms 

$vidurl = Array ([0] => Array ([0] => www.youtube.com/video/bOejnFiC88E [1] => www.youtube.com/video/FsVAxrvi6iE [2] => www.youtube.com/video/3lGfTZdVK1s [3] => www.youtube.com/video/hcw8dl73-W4 [4] => www.youtube.com/video/NlHJ5njWVFE [5] => www.youtube.com/video/II68oVm4zro [6] => www.youtube.com/video/tpg9IaOfno4 [7] => www.youtube.com/video/mzbG0JAICu8 [8] => www.youtube.com/video/OgPodRbJ3So [9] => www.youtube.com/video/YfPLB30MSCU 

$vidtitle = Array ([0] => Array ([0] => Gesture Control [1] => Volkswagen – Parkmobile [2] => Multi Collision braking system [3] => Mobiele telefoon interface Premium [4] => Maps & More Dock in de up! [5] => Lane Assist [6] => Car-Net Connect [7] => Volkswagen Allesdrager [8] => Volkswagen Bagagebox [9] => Volkswagen fietsendrager 

的陣列都以相同的順序,所以值爲1的$ vidtype比賽價值的$ vidcategory 1,$ vidurl和$ vidtitle。我將它們導出到excel文件,但要按字母順序對$ vidtype和$ vidtitle進行排序。

如果我這樣做,數組值將不再匹配,所以我的想法是合併所有的值與相同的密鑰在一起,並按合併後的字母順序排序$ vidtype和$ vidtitle。所以這些值仍然會匹配。

我被困在合併的一部分,我一直在尋找的計算器了很久也沒有找到正確的答案。

是我的想法清楚了嗎?有什麼想法嗎?

+0

的可能的複製[合併兩個數組(http://stackoverflow.com/questions/6535444/combine-two-arrays) –

+0

您可以創建一個數組,並將其合併到一。然後按任何字段排序數據。 – Evgeniy

+0

嘗試array_push合併所有數組 – Umar

回答

2

這將工作

$abc=array(); 
for($i=0;$i<10;$i++){ 
$abc[$i]=array($vidtype[$i],$vidcategory[$i],$vidurl[$i],$vidtitle[$i]); 
} 
+0

我得到這樣的通知:未定義抵消:1,好像該結構是好的,因爲我得到這個返回:[1] =>陣列([0] => [1] = > [2] => [3] =>) –

+0

是否可以發送屏幕拍攝? –

+0

明白了,謝謝! –

相關問題