I get two arrays from
$check = getmxrr ( $domain, $mxhosts, $weight );
I want to get the mxhosts in a third array from lowest to highest weight.
For simplicity let's have simple array names and values:
$s = array('slowest','fast','very slow', 'slow','very fast', 'fastest');
$n = array( 40, 10, 30, 20, 5, 0 );
Now, with this code, I can get the ordered array I'm looking for:
$o = array_combine($n, $s);
ksort($o);
But, if there are elements with the same weight, only the last element with the repeated weight would appear in the ordered array.
Is there any similar (low footprint) solution without this issue?
Illustrative cases follow.
Weight values are unique. Output is OK:
[0] => fastest [5] => very fast [10] => fast [20] => slow [30] => very slow [40] => slowest
We have same-weight elements. Output is NOT OK (fast is gone):
$n = array( 40, 10, 30, 10, 20, 5, 0 );
$s = array('slowest','fast','very slow','fast2', 'slow','very fast', 'fastest');
[0] => fastest [5] => very fast [10] => fast2 [20] => slow [30] => very slow [40] => slowest