<?php $array = [ ["444", "0081"], ["449", "0081"], ["451", "0081"], ["455", "2100"], ["469", "2100"] ]; $result = []; foreach ($array as $row) { if (!isset($ref[$row[1]])) { $ref[$row[1]] = $row; $result[] = &$ref[$row[1]]; } else { $ref[$row[1]][0] .= ',' . $row[0]; } } var_export($result);
You have javascript disabled. You will not be able to edit any code.