3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ ['DEPARTMENT_ID_FK' => '001', 'EMAIL_ADDRESS' => 'a@example.com'], ['DEPARTMENT_ID_FK' => '002', 'EMAIL_ADDRESS' => 'a@example.com'], ['DEPARTMENT_ID_FK' => '001', 'EMAIL_ADDRESS' => 'c@example.com'], ]; $agg = []; foreach ($data as $dData) { $dep = $dData['DEPARTMENT_ID_FK']; $email = $dData['EMAIL_ADDRESS']; if (isset($agg[$dep])) { $agg[$dep][] = $email; continue; } $agg[$dep] = [$email]; } $result = []; foreach ($agg as $dep => $emails) { $result[] = [ 'DEPARTMENT_ID_FK' => $dep, 'EMAIL_ADDRESS' => implode(',', $emails), ]; } print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [DEPARTMENT_ID_FK] => 001 [EMAIL_ADDRESS] => a@example.com,c@example.com ) [1] => Array ( [DEPARTMENT_ID_FK] => 002 [EMAIL_ADDRESS] => a@example.com ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
166.31 ms | 406 KiB | 5 Q