3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allOptions = [ ["clID" => 171], ["clID" => 191], ["clID" => 131], ["clID" => 101], ["clID" => 201], ["clID" => 181], ["clID" => 99], // not in regOptions ["clID" => 129], // not in regOptions ["clID" => 139], ]; $regOptions = [ ["order" => 1, "optID" => 131], ["order" => 2, "optID" => 191], ["order" => 3, "optID" => 181], ["order" => 4, "optID" => 139], ["order" => 5, "optID" => 101], ["order" => 6, "optID" => 201], ["order" => 7, "optID" => 171], ]; $priority = array_column($regOptions, 'order', 'optID'); usort( $allOptions, fn($a, $b) => ($priority[$a['clID']] ?? PHP_INT_MAX) <=> ($priority[$b['clID']] ?? PHP_INT_MAX) ); var_export($allOptions);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
array ( 0 => array ( 'clID' => 131, ), 1 => array ( 'clID' => 191, ), 2 => array ( 'clID' => 181, ), 3 => array ( 'clID' => 139, ), 4 => array ( 'clID' => 101, ), 5 => array ( 'clID' => 201, ), 6 => array ( 'clID' => 171, ), 7 => array ( 'clID' => 99, ), 8 => array ( 'clID' => 129, ), )

preferences:
110.45 ms | 403 KiB | 91 Q