Level 104
Assuming the 22 is a typo:
_.toArray(_.groupBy(arrayOfIds, (i) => i))
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everybody, I have an array of ids, I want to have an array of arrays each containing their unique values, for example if I have an array like this:
let arrayOfIds = [ 1,2,2,4,2,4,5,5 ];
I want to get a resulting array ike the following:
[
[1],
[22,2],
[4],
[5,5]
]
Thanks in advance
Please or to participate in this conversation.