similartext php,similar_text - PHP 5 中文文档

本文详细介绍了PHP内置函数similar_text的用法,它用于计算两个字符串的相似度。根据Oliver在1993年的描述,这个函数通过递归调用来实现。需要注意的是,此算法的时间复杂度为O(N^3),其中N为最长字符串的长度。此外,通过传递第三个参数,可以获取字符串相似度的百分比。除了similar_text,还提到了其他字符串处理函数如levenshtein和soundex。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(PHP 3 >= 3.0.7, PHP 4, PHP 5)

similar_text–

Calculate the similarity between two strings

Description

int similar_text

( string first, string second [, float &percent] )

This calculates the similarity between two strings as described

in Oliver [1993]. Note that this implementation does not use a

stack as in Oliver’s pseudo code, but recursive calls which may

or may not speed up the whole process. Note also that the

complexity of this algorithm is O(N**3) where N is the length of

the longest string.

By passing a reference as third argument,

similar_text()

will calculate the similarity

in percent for you. It returns the number of matching chars in

both strings.

See also levenshtein()

, and soundex()

.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值