PHP similar_text() Function
Complete PHP String Reference
Definition and Usage
The similar_text() function returns the number of matching characters of two
strings.
It can also calculate the similarity of the two strings in percent.
Syntax
|
similar_text(string1,string2,percent)
|
| Parameter |
Description |
| string1 |
Required. Specifies the first string to be compared |
| string2 |
Required. Specifies the second string to be compared |
| percent |
Optional. Specifies a variable name for storing the
similarity in percent |
Tips and Notes
Note: The levenshtein() function is faster than the similar_text()
function. However, the similar_text() function will give you a more accurate
result with less modifications needed.
Example 1
<?php
echo similar_text("Hello World","Hello Peter");
?>
|
The output of the code above will be:
Example 2
<?php
similar_text("Hello World","Hello Peter",$percent);
echo $percent;
?>
|
The output of the code above will be:
Complete PHP String Reference
Stylus Studio® 2010 XML Enterprise Suite raises the bar for productivity in XML development tools.
Millions of XML developers and data integration specialists turn to Stylus Studio's comprehensive and intuitive
XML toolset to tackle today's advanced XML data transformation and aggregation challenges.
|
- XML Pipeline Editor, Debugger and Code Generator
- DataDirect XML Converters
- XQuery Mapper, Editor, Debugger, and Profiler
- XSLT Mapper, Editor, Debugger, Designer, and Profiler
- Java and C# for .Net Code Generation
- XML Schema Designer With Documentation Generator
- XML Editor With Full XPath Integration
Download a free trial now
|
|