I want to split an array according to sub_id
my main array:
$my_main_array = [
['id' => 1, 'sub_id' => 8],
['id' => 2, 'sub_id' => 9],
['id' => 3, 'sub_id' => 8],
['id' => 3, 'sub_id' => 9],
['id' => 3, 'sub_id' => 9],
];
The result should be,The first array:
sub_id equal 8
sub_id equal 8
The second array
sub_id equal 9
sub_id equal 9
sub_id equal 9