fork download
  1. <?php
  2. $words = array("jack", "jacker", "jackman");
  3. $scores = array();
  4. $checkAgainst = "jackman";
  5.  
  6. // Calculating scores
  7. for($i=0; $i < count($words); $i++) {
  8. similar_text($checkAgainst, $words[$i], $score);
  9. $scores[$i] = $score;
  10. }
  11.  
  12. // Sorting
  13. array_multisort($scores, SORT_NUMERIC, SORT_DESC, $words, SORT_REGULAR);
  14. print_r($words);
  15. print_r($scores);
  16. ?>
  17.  
  18.  
  19.  
  20.  
  21.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => jackman
    [1] => jack
    [2] => jacker
)
Array
(
    [0] => 100
    [1] => 72.727272727273
    [2] => 61.538461538462
)