I have the following php array and would like to group the results:
array:3 [▼
1 => array:4 [▼
"trashed" => 1
"passed" => 0
"failed" => 2
"unknown" => 0
]
2 => array:4 [▼
"trashed" => 0
"passed" => 1
"failed" => 0
"unknown" => 3
]
3 => array:4 [▼
"trashed" => 0
"passed" => 0
"failed" => 0
"unknown" => 0
]
]
How can i group them for example: without going through loops? I would love to learn about an array_sort or merge function that does this :D
$trashed = [1, 0, 0];
$passed = [0, 1, 0];
I can rename the $key to anything if numbers is better approach or may assist in answering the question.
There will not be any null $keys or $values in this.
I'm currently doing it like this, but it seems ugly:
$trashed = [];
foreach($months as $month){
array_push($trashed, $month['trashed']);
}