★ wanayoo — archive 1999 http://www.php.net/manual/it/function.similar-text.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Strings
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageFrench version of this pageHungarian version of this page
Strings
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* htmlentities
* htmlspecialchars
* implode
* join
* ltrim
* md5
* Metaphone
* nl2br
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* QuoteMeta
* rawurldecode
* rawurlencode
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* StripCSlashes
* StripSlashes
* stristr
* strlen
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_replace
* trim
* ucfirst
* ucwords
Manual: similar_text
View the source code for this pageSearch the site



Previous page
 setlocale
 Updated
Sun, 06 Aug 2000
soundex 
Next page


similar_text

(PHP3 >= 3.0.7, PHP4 >= 4.0b2)

similar_text --  Calculate the similarity between two strings.

Description

int similar_text (string first, string second [, double percent])

This calculates the similarity between two strings as described in Oliver [1993]. Note that this implementation does not use a stack as in Oliver's pseudo code, but recursive calls which may or may not speed up the whole process. Note also that the complexity of this algorithm is O(N**3) where N is the length of the longest string.

By passing a reference as third argument, similar_text() will calculate the similarity in percent for you. It returns the number of matching chars in both strings.


User Contributed Notes: similar_text


mogmios@hushmail.com
01-Feb-2000 05:39
$i = similar_text($first_word, $second_word, &$p);
echo("Matched: $i Percentage: $p%");

Don't forget your passing the double as a reference. If you use this and soundex() together you can get a pretty good guess as to how well two words match. Is useful for simple bot-like programs.



r.m.peters@omnidata.nl
08-Aug-2000 09:11
Where can i find the pseudo-code of oliver 1993.
Thanks Ronald



 About Notes


Previous page
 setlocale
 Updated
Sun, 06 Aug 2000
soundex 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.