PHP similar_text function definition and usage similar noun similar as be similar a

Source: Internet
Author: User
PHP similar_text () function calculates the similarity of two strings, this article introduces the basic use method and basic use example of PHP similar_text () function, and the code farmer of Interest can refer to it.

Definition and usage

The Similar_text () function calculates the similarity of two strings.

The function can also calculate the percent similarity of two strings.

Note: the Levenshtein () function is faster than the Similar_text () function. However, the Similar_text () function provides more precise results with fewer required modifications.

Grammar

Similar_text (string1,string2,percent)

Parameters Description
String1 Necessary. Specifies the first string to compare.
string2 Necessary. Specifies a second string to compare.
Percent Optional. A variable name that specifies the similarity of the storage percentage.
Technical details
return value: Returns the number of matching characters for a two string.
PHP version: 4 +
Instance

Calculates the percent similarity between two strings:

<?phpsimilar_text ("Hello World", "Hello Shanghai", $percent); Echo $percent. "%";? >

The above PHP similar_text () function definition and usage is the small part of the whole content to share to everyone, I hope to give you a reference, but also hope that we support this site a lot.

The above describes the PHP similar_text function definition and usage, including the contents of the Similar,text function, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.