searchSort

Description

Callback function for usort used to sort the fulltext results.

Syntax

int searchSort (string $a, string $b)



Parameter $a

Expected type: String
Description: A word



Parameter $b

Expected type: String
Description: Another word



Return value

Expected type: Enumerated Integer
Description: Indicates which item is more important (see PHP manual on usort for more info)

Possible integer values
Allowed values Description
-1 If using fulltext index, this indicates that $a is more important than $b; otherwise it means $b is more important (importance based on length and whether or not each word is excluded from the search)
0 $a and $b are equally important (regardless of search method)
1 If you're using a fulltext index, this indicates that $b is more important than $a; otherwise it means $a is more important than $b


Notes

  • The order of sorting is: large words, small words, large words that are excluded from the search, small words that are excluded.
  • See http://www.php.net/usort for more information on usort
  • Finds the length of each word
  • Subtracts 1000 from the length if the word is excluded
  • Compares the results of the length calculation for both variables
Advertisement: