3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'product2' => [ 'dates' => [ '2013-07-25' => 2, '2013-07-23' => 1, '2013-07-21' => 3 ] ], 'product3' => [ 'dates' => [ '2013-07-24' => 5, '2013-07-22' => 4, '2013-07-20' => 3 ] ], 'product1' => [ 'dates' => [ '2013-07-29' => 1, '2013-07-28' => 2, '2013-07-27' => 2 ] ] ]; function rksort(&$array) { ksort($array); foreach ($array as &$v) { if (is_array($v)) { (__FUNCTION__)($v); } } } rksort($array); var_export($array);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 'product1' => array ( 'dates' => array ( '2013-07-27' => 2, '2013-07-28' => 2, '2013-07-29' => 1, ), ), 'product2' => array ( 'dates' => array ( '2013-07-21' => 3, '2013-07-23' => 1, '2013-07-25' => 2, ), ), 'product3' => array ( 'dates' => array ( '2013-07-20' => 3, '2013-07-22' => 4, '2013-07-24' => 5, ), ), )

preferences:
59.52 ms | 1037 KiB | 4 Q