如何在数组中对值进行分组,作为一个例子,我希望像这样得到它
[1]=>array(
["type"] => 1
["amount"] => array(2500,200,5000,400)
)
[2]=>array(
["type"] => 2
["amount"] => array(4500,500,5000,400)
)
答案 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);