Core Function SimilarText
From Sputnik Wiki
(Difference between revisions)
UberFoX (Talk | contribs)
(Created page with "<pre> SimilarText( <first>, <second>, <percent> ) </pre> === Description === Calculates the similarity between two input strings and return a percentage of the matching between...")
Newer edit →
(Created page with "<pre> SimilarText( <first>, <second>, <percent> ) </pre> === Description === Calculates the similarity between two input strings and return a percentage of the matching between...")
Newer edit →
Revision as of 20:58, 13 August 2013
SimilarText( <first>, <second>, <percent> )
Contents |
Description
Calculates the similarity between two input strings and return a percentage of the matching between the two input strings.
Parameters
first
The first string.
second
The second string.
percent
Optional; A variable that will be set to the similarity in percent.
Return Value
Returns the number of matching chars in both strings.
Remarks
The first two are the strings you want to compare.
The percent tells you how accurate, in percentage terms, the match was.
This is optional, though, so you can leave it out.
Example
Here's an example that tells the user how accurately they entered a username:
$real_username ="Bill Gates"; $user_attempt = "Bill Bates"; $check = SimilarText($real_username, $user_attempt, $percent); print("Check: " . $check . "\n"); print("Percent: " . $percent . "% correct\n");