3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<JSON [ { "id": 99961, "candidate": { "data": { "id": 125275, "firstName": "Jose", "lastName": "Zayas" } }, "dateAdded": 1667995574207 }, { "id": 99960, "candidate": { "data": { "id": 125274, "firstName": "CHRISTIAN", "lastName": "NEILS" } }, "dateAdded": 1667986477133 }, { "id": 99959, "candidate": { "data": { "id": 125273, "firstName": "Jose", "lastName": "Zayas" } }, "dateAdded": 1667985600420 }, { "id": 99958, "candidate": { "data": { "id": 125275, "firstName": "Jose", "lastName": "Zayas" } }, "dateAdded": 1667985600420 } ] JSON; $array = json_decode($json, true); $grouped = []; foreach ($array as $row) { $compositeKey = "{$row['candidate']['data']['firstName']} {$row['candidate']['data']['lastName']}"; $grouped[$compositeKey][$row['candidate']['data']['id']] = $row['candidate']['data']['id']; } $result = []; foreach ($grouped as $id => $group) { if (count($group) > 1) { $result[$id] = array_values($group); } } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'Jose Zayas' => array ( 0 => 125275, 1 => 125273, ), )

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:
75.15 ms | 405 KiB | 5 Q