I have an array:
array(
"A1" => 4,
"A2" =>5,
"B1" => 2,
"B2" =>7,
"C1" => 4,
"C2" =>5,
"D1" => 4,
"D2" =>5,
.....
)
Now I just want to new array:
$arr1 = array("A"=>array("A1"=>4, "A2"=>5), "B" => array("B1" => 2, "B2" => "7"), ...)
$arr2 = array(
0=>array("A1"=>"4","B1"=>2,"C1"=>4,"D1"=>4),
1=>array("A2"=>"4","B2"=>2,"C2"=>4,"D2"=>4)
)
Help me, how can I group the array?
Outputs:
This should work for you:
Output: