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);
Output for git.master, git.master_jit
array ( 'product3' => array ( 'id' => 3, 'title' => 'p3', 'extra' => array ( 'date' => '2000-01-04 16:40:26', ), ), 'product4' => array ( 'id' => 4, 'title' => 'p4', 'extra' => array ( 'date' => '1995-01-04 16:40:26', ), ), 'product1' => array ( 'id' => 1, 'title' => 'p1', 'extra' => array ( 'date' => '1990-02-04 16:40:26', ), ), 'product2' => array ( 'id' => 2, 'title' => 'p2', 'extra' => array ( 'date' => '1980-01-04 16:40:26', ), ), 'product5' => array ( 'id' => 5, 'title' => 'p5', 'extra' => array ( 'date' => '1960-01-04 16:40:26', ), ), )

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:
59.53 ms | 908 KiB | 4 Q