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

Need an easy way to get data into XML, or transform XML to another format?
MapForce lets you map XML data to/from any combination of XML, database, flat file, Excel 2007, XBRL, or Web services data.
Then it transforms data instantly or auto-generates royalty-free data integration code for recurrent conversions.
Download a free, fully functional 30-day trial to experience the following features:
- Easy-to-use, graphical data mapping interface
- Instant data transformation
- XSLT 1.0/2.0 and XQuery code generation
- Java, C#, and C++ code generation
- Advanced data processing functions
- Support for all major relational databases including SQL Server, IBM DB2, Oracle, and more
- Visual Studio & Eclipse integration
Download a fully-functional trial today!
|
|
|
|