3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = '{"id":41,"userId":9,"description":null,"updated_by":"Juan Dela Cruz","created_at":"2019-09-18 10:07:34","updated_at":"2019-09-18 10:07:34"}'; $b = '{"id":2,"userId":9,"description":null,"updated_by":null,"created_at":"2019-09-16 12:46:56","updated_at":"2019-09-16 12:46:56"}'; $arr1 = json_decode($a, true); $key1 = strtotime($arr1['created_at']); $arr[$key1] = $arr1; $arr2 = json_decode($b, true); $key2 = strtotime($arr2['created_at']); $arr[$key2] = $arr2; //print_r($arr); $key = max(array_keys($arr)); print_r($arr[$key]);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
Array ( [id] => 41 [userId] => 9 [description] => [updated_by] => Juan Dela Cruz [created_at] => 2019-09-18 10:07:34 [updated_at] => 2019-09-18 10:07:34 )

preferences:
144.36 ms | 408 KiB | 5 Q