I have two array $days_order and $mysql_result, I want to sort $mysql_result array using $days_order array. I want to display
$days_order
$mysql_result
Use usort with a custom compare function.
usort
Something like:
usort($ranked, function($a, $b) { if ($a['day'] === $b['day']) return 0; return ($a['day'] > $b['day']) ? -1 : 1; });
You can read more about this function here.