3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
150.9 ms | 1524 KiB | 11 Q