3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myarray = array( [ 'messageId' => '5ACE9D8841', 'sender' => 'john@doe.com', ], [ 'messageId' => '7EE67D8170', 'sender' => 'dan@doe.com', ], [ 'messageId' => '8095FD8836', 'sender' => 'cat@doe.com', ], [ 'messageId' => ['brokenId' => '8095FD8836'], 'sender' => 'cat@doe.com', ], [ 'status' => 'wrong row', ], [ 'messageId' => '7EE67D8170', 'dest' => 'mitch@doe.com', 'status' => 'sent', 'date' => '2021-02-01 11:06:55', ], ); $result = array_reduce($myarray, function($rows, $item){ if (array_key_exists('messageId', $item) && is_scalar($item['messageId'])) { $rows = array_replace_recursive($rows ?? [], [$item['messageId'] => $item]); } return $rows; }); $result = array_values($result); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [messageId] => 5ACE9D8841 [sender] => john@doe.com ) [1] => Array ( [messageId] => 7EE67D8170 [sender] => dan@doe.com [dest] => mitch@doe.com [status] => sent [date] => 2021-02-01 11:06:55 ) [2] => Array ( [messageId] => 8095FD8836 [sender] => cat@doe.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:
132.3 ms | 406 KiB | 5 Q