php similar_text(),phpsimilar_text
php similar_text() 函数计算比较两个字符串的相似度,本文章向码农介绍php similar_text() 函数的基本使用方法和基本使用实例,感兴趣的码农可以参考一下。
定义和用法
similar_text() 函数计算两个字符串的相似度。
该函数也能计算两个字符串的百分比相似度。
注释:levenshtein() 函数比 similar_text() 函数更快。不过,similar_text() 函数通过更少的必需修改次数提供更精确的结果。
语法
similar_text(string1,string2,percent)
参数 | 描述 |
---|---|
string1 | 必需。规定要比较的第一个字符串。 |
string2 | 必需。规定要比较的第二个字符串。 |
percent | 可选。规定供存储百分比相似度的变量名。 |
技术细节
返回值: | 返回两个字符串的匹配字符的数目。 |
PHP 版本: | 4+ |
实例
计算两个字符串之间的百分比相似度:
<?<span>php </span><span>similar_text</span>("Hello World","Hello Shanghai",<span>$percent</span><span>); </span><span>echo</span> <span>$percent</span>. "%"<span>; </span>?>
在线运行
原文地址:http://www.manongjc.com/article/805.html
php相关学习:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft