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

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 中的 soundex() 函数


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

Definition and Usage
定义和用法

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

A soundex key is a four character long alphanumeric string that represent English pronunciation of a word.
一个soundex键是由一个四字符长度的alphanumeric字符串组成的,它代表了一个单词的英文发音。

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

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

Syntax
语法

soundex(string)

Parameter参数 Description描述
string Required. Specifies the string to check
必要参数。指定字符串对象


Tips and Notes
提示和注意点

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

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


Example 1
案例1

<?php
$str = "hello";
echo soundex($str);
?>

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

H400


Example 2
案例2

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

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

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

S500
S500

评论 (0) All

登陆 | 还没注册?