<?php $array = [ 'product1' => [ 'id' => 1, 'title' => 'p1', 'extra' => [ 'date' => '1990-02-04 16:40:26' ] ], 'product2' => [ 'id' => 2, 'title' => 'p2', 'extra' => [ 'date' => '1980-01-04 16:40:26' ] ], 'product3' => [ 'id' => 3, 'title' => 'p3', 'extra' => [ 'date' => '2000-01-04 16:40:26' ] ], 'product4' => [ 'id' => 4, 'title' => 'p4', 'extra' => [ 'date' => '1995-01-04 16:40:26' ] ], 'product5' => [ 'id' => 5, 'title' => 'p5', 'extra' => [ 'date' => '1960-01-04 16:40:26' ] ] ]; $cache = $array; uasort($array, fn($a, $b) => $b['extra']['date'] <=> $a['extra']['date']); var_export(array_slice($array, 0, 2) + $cache);
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`