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

PHP
PHP 介绍
PHP 安装
PHP 语法
PHP 变量
PHP操作符
PHP If...Else
PHP Switch
PHP 数组
PHP 循环
PHP 函数
PHP 表单
PHP $_GET
PHP $_POST
PHP Date
PHP Include
PHP 文件处理
PHP 文件上传
PHP Cookies
PHP Sessions
PHP 发送邮件

PHP 中的 soundex() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 528 ::
收藏到网摘: 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

登陆 | 还没注册?