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

Whether you're new to XML or already an advanced user,
the user-friendly views and powerful entry helpers,
wizards, and debuggers in XMLSpy are designed to meet your XML
and Web development needs from start to finish.
New features in Version 2010!
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- XBRL validator, taxonomy editor, taxonomy wizard
- Support for Office Open XML (OOXML)
- Graphical WSDL 1.1/2.0 editor & SOAP debugger
- JSON editing & conversion
- Java, C#, C++ code generation
- And much more!
Download a free trial today!
|
|
|
|