PHP 8 behaves slightly different with in_array and usort

This commit is contained in:
Marc Tobias
2022-05-10 18:30:49 +02:00
parent bc63f10057
commit ccf119206d
4 changed files with 28 additions and 4 deletions

View File

@@ -120,13 +120,18 @@ class SimpleWordList
return array_slice($aWordSets, 0, SimpleWordList::MAX_WORDSETS);
}
/**
* Custom search routine which takes two arrays. The array with the fewest
* items wins. If same number of items then the one with the longest first
* element wins.
*/
public static function cmpByArraylen($aA, $aB)
{
$iALen = count($aA);
$iBLen = count($aB);
if ($iALen == $iBLen) {
return 0;
return strlen($aB[0]) <=> strlen($aA[0]);
}
return ($iALen < $iBLen) ? -1 : 1;