Cha*_*yan 4 javascript php string comparison
我想比较三个字符串:
"a text string" //target string
"a kind of similar text string"
"the cow jumps over the moon"
Run Code Online (Sandbox Code Playgroud)
并设置一个百分比参数,该参数返回与目标类似的x%结果.
$results = compare($array,$target,80)
$results // Returns an array with str 1,2, because they are at least 80 similar to the target.
Run Code Online (Sandbox Code Playgroud)
此外,在JavaScript或jQuery中可能有类似的功能吗?
在PHP中,有功能similar_text.至于JavaScript,有PHP.js项目,它在JavaScript中重新实现PHP函数.他们有一个similar_text你可以使用的实现.
似乎JavaScript实现不支持百分比参数.
| 归档时间: |
|
| 查看次数: |
422 次 |
| 最近记录: |