There seems to be an undocumented change to how PHP 7 handles equal results in usort functions.
$myArray = array(1, 2, 3);
usort($myArray, function($a, $b) { return 0; });
print_r($myArray);
// PHP 5:
Array
(
[0] => 3
[1] => 2
[2] => 1
)
// PHP 7
Array
(
[0] => 1
[1] => 2
[2] => 3
)
In other words in PHP 7, usort is adding equal values to the end of the array, whereas PHP 5 adds them to the beginning. I can't find any mention of this behaviour.
Is there a way of forcing the PHP 5 behaviour?
usort
was ever guaranteed to be stable nor was the sort order of equal elements ever defined. If you relied on the undefined behaviour, you need to change your approach.