Core Function SimilarText

From Sputnik Wiki
Jump to: navigation, search
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");
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox