Home > Backend Development > PHP Tutorial > Definition and usage of php metaphone() function, phpmetaphone_PHP tutorial

Definition and usage of php metaphone() function, phpmetaphone_PHP tutorial

WBOY
Release: 2016-07-12 08:52:01
Original
1073 people have browsed it

Definition and usage of php metaphone() function, phpmetaphone

php metaphone() function calculates the metaphone key of a string, this article introduces the php metaphone() function to coders For basic usage and examples, coders in need can refer to the methods and examples in this article.

Definition and usage

The metaphone() function calculates the metaphone key of a string.

The metaphone key represents the English pronunciation of the string.

The metaphone() function can be used in spell checkers.

Note: The metaphone() function creates the same key for words that sound similar.

Note: The generated metaphone keys are of variable length.

Tip: metaphone() is more precise than the soundex() function because metaphone() understands the basic rules of English pronunciation.

Grammar

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

Technical details

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

Example

Example 1

Use the metaphone() function for two words that sound similar:

<&#63;php 
$str = "Assistance"; 
$str2 = "Assistants"; 
 
echo metaphone($str); 
echo "<br>"; 
echo metaphone($str2); 
&#63;> 
Copy after login

Example 2

Use length parameter:

<&#63;php 
$str = "Assistance"; 
$str2 = "Assistants"; 
 
echo metaphone($str,5); 
echo "<br>"; 
echo metaphone($str2,5); 
&#63;> 
Copy after login

The above definition and usage of the php metaphone() function is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127893.htmlTechArticleDefinition and usage of php metaphone() function, phpmetaphone php metaphone() function calculates the metaphone key of a string, this This article introduces to coders the basic usage and implementation of the php metaphone() function...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template