PHP/String/similar text

Материал из Web эксперт
Перейти к: навигация, поиск

Checking for Similar Names

   <source lang="html4strict">

<?php $names = array("A", "B","R", "R"); $output = ""; foreach ($names as $name) {

   similar_text($name, "Roberto Smyth", $percent);
   $output .= "{$name} = {$percent}%\n";

}

echo "
{$output}
";

?>

 </source>
   
  


Determine the similarity between two strings is provided by the similar_text function

   <source lang="html4strict">

<?php

   $matches = similar_text ("see", "say", &$per);
   echo "Matches: $matches - Percentage: $per\n";

?>

 </source>