Sorts merged array by datetime

PHOTO EMBED

Mon Apr 12 2021 09:41:59 GMT+0000 (UTC)

Saved by @pots07 #php

// merge arrays and sort by datetime
$arr = array_merge($arr1, $arr2);
usort($arr, function($a, $b) {
  $date1 = strtotime($a->datetime);
  $date2 = strtotime($b->datetime);
  return $date1 - $date2;     // ascending order, swop around for descending order
});
content_copyCOPY