2015-11-08 89 views
0

我想添加這樣的數組。如何在PHP中添加陣列

$a1=["red","green"]; 
$a2=["blue","yellow"]; 

添加3門陣列這樣

$main_array=[["red","green"],["blue","yellow"]]; 

我試圖陣列合併,但它這樣做:

$main_array=["red","yellow","blue","green"]; 

回答

0

嘗試多維數組

$a1=array("red","green"); 
$a2=array("blue","yellow"); 

$main_array=array($a1,$a2); 
print_r($main_array); 
+0

HAHA LOL真的:)我現在發現自己很內疚:D – stlawrance