如何创建阵列组

时间:2012-03-20 05:57:08

标签: php arrays

如何在数组中对值进行分组,作为一个例子,我希望像这样得到它

[1]=>array(
   ["type"] => 1
   ["amount"] => array(2500,200,5000,400)
)
[2]=>array(
   ["type"] => 2
   ["amount"] => array(4500,500,5000,400)
)

1 个答案:

答案 0 :(得分:2)

您可以使用以下代码: -

$ps = array();
$ps[]=array("type" => 1,  "amount" => array(2500,200,5000,400));
$ps[]=array("type" => 2 ,  "amount" => array(4500,500,5000,400));

print_r($ps);