23

wmatch

wmatch
SYNOPSIS

wmatch($word, $wl, $dlimit=0, $closest=true)

DESCRIPTION
CODE
  1. require_once 'strflat.php';
  2.  
  3. function wmatch($word, $wl, $dlimit=0, $closest=true) {
  4.     $word = strtolower(strflat($word));
  5.     $ret = false;
  6.  
  7.     foreach ($wl as $w) {
  8.         $d = levenshtein($word, strtolower(strflat($w)));
  9.  
  10.         if ($d < 0) {
  11.             continue;
  12.         }
  13.  
  14.         /* DON'T return immediately if $d is 0 to be case and accent insensitive */
  15.  
  16.         if ($d <= $dlimit) {
  17.             if ($closest && $d < $dlimit) {
  18.                 $ret=array($w);
  19.                 $dlimit=$d;
  20.             }
  21.             else {
  22.                 $ret[]=$w;
  23.             }
  24.         }
  25.     }
  26.  
  27.     return $ret;
  28. }

Commentaires

Votre commentaire :
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip aide 2000

Entrez un maximum de 2000 caractères.
Améliorez la présentation de votre texte avec les balises de formatage suivantes :
[p]paragraphe[/p], [b]gras[/b], [i]italique[/i], [u]souligné[/u], [s]barré[/s], [quote]citation[/quote], [pre]tel quel[/pre], [br]à la ligne,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]commande[/code], [code=langage]code source en c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].