Heim  >  Artikel  >  Backend-Entwicklung  >  php metaphone()函数解析,phpmetaphone_PHP教程

php metaphone()函数解析,phpmetaphone_PHP教程

WBOY
WBOYOriginal
2016-07-12 08:52:37838Durchsuche

php metaphone()函数解析,phpmetaphone

php metaphone() 函数计算字符串的 metaphone 键,本文章向码农们介绍 php metaphone() 函数的基本用法和实例,需要的码农可以参考一下本文章的方法和实例。

定义和用法

metaphone() 函数计算字符串的 metaphone 键。

metaphone 键代表字符串的英语发音。

metaphone() 函数可用于拼写检查程序。

注释:metaphone() 函数为发音相似的单词创建相同的键。

注释:所生成的 metaphone 键长度可变。

提示:metaphone() 比 soundex() 函数更精确,因为 metaphone() 了解英语发音的基本规则。

 

语法

metaphone(string,length)

  

参数 描述
string 必需。规定要检查的字符串。
length 可选。规定 metaphone 键的最大长度。

 

技术细节

返回值: 如果成功则返回字符串的 metaphone 键,如果失败则返回 FALSE。
PHP 版本: 4+

 

实例

例子 1

对两个发音相似的单词使用 metaphone() 函数:

<?php
$str = "Assistance";
$str2 = "Assistants";

echo metaphone($str);
echo "<br>";
echo metaphone($str2);
?>

在线运行

例子 2

使用 length 参数:

<?php
$str = "Assistance";
$str2 = "Assistants";

echo metaphone($str,5);
echo "<br>";
echo metaphone($str2,5);
?>

在线运行

原文地址:http://www.manongjc.com/article/816.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1126419.htmlTechArticlephp metaphone()函数解析,phpmetaphone php metaphone() 函数计算字符串的 metaphone 键,本文章向码农们介绍 php metaphone() 函数的基本用法和实例,需要...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn