3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ 'admin' => [ [ 'id' => 3, 'user_type' => 'Accountant', 'latest_user_activity_date' => '2000-01-01 00:00:00', 'full_link' => 'admin/billing_contacts.app', ], [ 'id' => 1, 'user_type' => 'Accountant', 'latest_user_activity_date' => '2018-04-19 13:18:59', 'full_link' => 'admin/billing_contacts.app', ], [ 'id' => 2, 'user_type' => 'Accountant', 'latest_user_activity_date' => '2018-04-15 13:18:59', 'full_link' => 'admin/billing_contacts.app', ], ], 'invoice' => [ [ 'id' => 3, 'user_type' => 'Accountant', 'latest_user_activity_date' => '2000-01-01 00:00:00', 'full_link' => 'admin/create_invoice.app', ], [ 'id' => 1, 'user_type' => 'Accountant', 'latest_user_activity_date' => '2018-04-19 13:18:59', 'full_link' => 'admin/create_invoice.app', ], [ 'id' => 2, 'user_type' => 'Accountant', 'latest_user_activity_date' => '2018-04-20 13:18:59', 'full_link' => 'admin/create_invoice.app', ], ], ]; function customSort(array $array) { // Iterate through and sort second level array by most recent date foreach ($array as $key => &$value) { usort($value, function ($a, $b) { return strtotime($a['latest_user_activity_date']) < strtotime($b['latest_user_activity_date']) ? 1 : -1; }); } // Sort first level array by date descending of first (most recent) entry uasort($array, function ($a, $b) { return strtotime($a[0]['latest_user_activity_date']) < strtotime($b[0]['latest_user_activity_date']) ? 1 : -1; }); return $array; } print_r(customSort($a));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [invoice] => Array ( [0] => Array ( [id] => 2 [user_type] => Accountant [latest_user_activity_date] => 2018-04-20 13:18:59 [full_link] => admin/create_invoice.app ) [1] => Array ( [id] => 1 [user_type] => Accountant [latest_user_activity_date] => 2018-04-19 13:18:59 [full_link] => admin/create_invoice.app ) [2] => Array ( [id] => 3 [user_type] => Accountant [latest_user_activity_date] => 2000-01-01 00:00:00 [full_link] => admin/create_invoice.app ) ) [admin] => Array ( [0] => Array ( [id] => 1 [user_type] => Accountant [latest_user_activity_date] => 2018-04-19 13:18:59 [full_link] => admin/billing_contacts.app ) [1] => Array ( [id] => 2 [user_type] => Accountant [latest_user_activity_date] => 2018-04-15 13:18:59 [full_link] => admin/billing_contacts.app ) [2] => Array ( [id] => 3 [user_type] => Accountant [latest_user_activity_date] => 2000-01-01 00:00:00 [full_link] => admin/billing_contacts.app ) ) )

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:
128.29 ms | 411 KiB | 5 Q