I have this code.
$shirts = [
['xl','silk','blue'],
['xl', 'cotton', 'red'],
['L', 'silk', 'green'],
['L', 'silk', 'black']
];
I want to group size . For example, I want output like this
$shirtbysize = [
'xl' =>
[
['silk','blue'],
['cotton','red']
],
'L' =>
[
['silk','green'],
['silk','black']
],
];
I searched everywhere but I didn't get answer. Can anyone tell me how to do this?