<?php $data = [ ["id" => 1, "begin" => "01/01", "diagnostic" => "a"], ["id" => 1, "begin" => "01/01", "diagnostic" => "b"], ["id" => 1, "begin" => "01/01", "diagnostic" => ""], ["id" => 1, "begin" => "02/02", "diagnostic" => "a"], ]; $result = []; foreach ($data as $row) { $compositeKey = $row['id'] . '-' . $row['begin']; if (!isset($result[$compositeKey])) { $result[$compositeKey] = $row; } elseif (strlen($row['diagnostic'])) { $result[$compositeKey]['diagnostic'] .= (strlen($result[$compositeKey]['diagnostic']) ? ', ' : '') . $row['diagnostic']; } } var_export(array_values($result));
You have javascript disabled. You will not be able to edit any code.