当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > metaphone() 函数

PHP
PHP 安全邮件
MySQL 介绍
连接 MySQL
创建 MySQL
MySQL 插入记录
MySQL 选择记录
MySQL Where
MySQL Order By
MySQL 记录更新
MySQL 删除记录
PHP ODBC
XML Expat Parser
XML SimpleXML
PHP 数组参考
PHP Calendar
PHP Date
PHP Directory
PHP Filesystem
PHP FTP
PHP HTTP

PHP 中的 metaphone() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 532 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The metaphone() function calculates the metaphone key of a string.
metaphone()函数的作用是:计算字符串的metaphone键。

A metaphone key represents how a string sounds if said by an English speaking person.
Metaphone键表示的是:指明一个字符的英文发音。

The metaphone() function can be used for spelling applications.
metaphone()函数可以应用于拼写。

This function returns the metaphone key of the string on success, or FALSE on failure.
如果这个函数执行成功,它将返回这个字符的metaphone键;如果执行失败将返回False。

Syntax
语法

metaphone(string,length)

Parameter参数 Description描述
string Required. Specifies the string to check
必要参数。指定字符串对象
length Optional. Specifies the maximum length of the metaphone key
可选参数。指定metaphone键的最大长度


Tips and Notes
提示和注意点

Note: The metaphone() function creates the same key for similar sounding words.
注意:metaphone()函数将为有着相似发音的单词创建相同的键。

Note: The generated metaphone keys vary in length.
注意:产生的metaphone键将依据长度发生变化。

Tip: metaphone() is more accurate than the soundex() function, because metaphone() knows the basic rules of English pronunciation.
提示:metaphone()函数比soundex()函数更加精确,因为metaphone()函数通晓英文发音的基本规则。


Example 1
案例1

<?php
echo metaphone("world");
?>

The output of the code above will be:
上述代码将输出下面的结果:

WRLT


Example 2
案例2

In this example we use the metaphone() function on two similar sounding words:
在下面的案例当中,我们将使用metaphone()函数对两个具有相同发音的单词进行操作:

<?php
$str = "Sun";
$str2 = "Son";
echo metaphone($str);
echo "<br />";
echo metaphone($str2);
?>

The output of the code above will be:
上述代码将输出下面的结果:

SN
SN

评论 (0) All

登陆 | 还没注册?