<?php $order = [7, 2, 1, 4]; $array = [ 1 => "O", 2 => "T", 4 => "F", 7 => "S" ]; uksort($array, static function (int $key1, int $key2) use ($order): int { return array_search($key1, $order, true) <=> array_search($key2, $order, true); }); print_r($array);
You have javascript disabled. You will not be able to edit any code.