PHP - 字串相似度函式



語法

int similar_text ( string $first , string $second [, float &$percent ] )

定義和用法

用於計算兩個字串之間的相似度。

返回值

返回兩個字串之間匹配的字元數。

引數

序號 引數及描述
1

第一個字串

包含第一個字串的資訊。

2

第二個字串

包含第二個字串的資訊。

3

百分比

透過將引用作為第三個引數傳遞,`similar_text()` 將為您計算相似度百分比。

示例

嘗試以下示例

<?php
   echo similar_text("Tutorials Point","Tutorials park");
?>

這將產生以下結果:

10
php_function_reference.htm
廣告