3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'id' => 2, 'type' => 'comment', 'text' => 'hey', 'datetime' => '2010-05-15 11:29:45' ], [ 'id' => 3, 'type' => 'status', 'text' => 'oi', 'datetime' => '2010-05-26 15:59:53' ], [ 'id' => 4, 'type' => 'status', 'text' => 'yeww', 'datetime' => '2010-05-26 16:04:24' ] ]; // usort() by date column DESC: usort($array, function($a, $b) { return $b['datetime'] <=> $a['datetime']; }); echo var_export($array, true) . "\n***\n"; // usort() by date column ASC: usort($array, function($a, $b) { return $a['datetime'] <=> $b['datetime']; }); echo var_export($array, true) . "\n***\n"; // usort() by date column ASC in >= PHP7.4: //usort($array, fn($a, $b) => $a['datetime'] <=> $b['datetime']); // array_multisort() by date column DESC: array_multisort(array_column($array, 'datetime'), SORT_DESC, $array); echo var_export($array, true) . "\n***\n"; // array_multisort() by date column ASC: array_multisort(array_column($array, 'datetime'), $array); echo var_export($array, true) . "\n***\n";
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => 4, 'type' => 'status', 'text' => 'yeww', 'datetime' => '2010-05-26 16:04:24', ), 1 => array ( 'id' => 3, 'type' => 'status', 'text' => 'oi', 'datetime' => '2010-05-26 15:59:53', ), 2 => array ( 'id' => 2, 'type' => 'comment', 'text' => 'hey', 'datetime' => '2010-05-15 11:29:45', ), ) *** array ( 0 => array ( 'id' => 2, 'type' => 'comment', 'text' => 'hey', 'datetime' => '2010-05-15 11:29:45', ), 1 => array ( 'id' => 3, 'type' => 'status', 'text' => 'oi', 'datetime' => '2010-05-26 15:59:53', ), 2 => array ( 'id' => 4, 'type' => 'status', 'text' => 'yeww', 'datetime' => '2010-05-26 16:04:24', ), ) *** array ( 0 => array ( 'id' => 4, 'type' => 'status', 'text' => 'yeww', 'datetime' => '2010-05-26 16:04:24', ), 1 => array ( 'id' => 3, 'type' => 'status', 'text' => 'oi', 'datetime' => '2010-05-26 15:59:53', ), 2 => array ( 'id' => 2, 'type' => 'comment', 'text' => 'hey', 'datetime' => '2010-05-15 11:29:45', ), ) *** array ( 0 => array ( 'id' => 2, 'type' => 'comment', 'text' => 'hey', 'datetime' => '2010-05-15 11:29:45', ), 1 => array ( 'id' => 3, 'type' => 'status', 'text' => 'oi', 'datetime' => '2010-05-26 15:59:53', ), 2 => array ( 'id' => 4, 'type' => 'status', 'text' => 'yeww', 'datetime' => '2010-05-26 16:04:24', ), ) ***

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:
56.87 ms | 410 KiB | 5 Q