1/* Collapse on common columns which is also the new key e.g.
2([0] => [[id] => 1234, [firstName] => "foo", [1] => [[id] => 1234, [lastName] => "bar")
3will become ([1234] => [[firstName] => "foo", [lastName]="bar"]
4Credit to https://stackoverflow.com/users/762073/xdazz
5*/
6$result = array();
7foreach ($data as $element) {
8 $result[$element['id']][] = $element;// [] appends to the array if it already exists
9}