How to create a group of arrays

How can I group values โ€‹โ€‹within an array and as an example, I want to get it like this:

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

      

+3


source to share


1 answer


the code below can be used for this: -



$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);

      

+2


source







All Articles