php metaphone() function analysis, phpmetaphone_PHP tutorial

WBOY
Release: 2016-07-12 08:52:37
Original
863 people have browsed it

php metaphone() function analysis, phpmetaphone

php metaphone() function calculates the metaphone key of a string. This article introduces the basic usage of php metaphone() function to coders. Coders who need it 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)
Copy after login

 

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

Technical details

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

Example

Example 1

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

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

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

Run online

Example 2

Use length parameter:

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

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

Run online

Original address: http://www.manongjc.com/article/816.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1126419.htmlTechArticlephp metaphone() function analysis, phpmetaphone php metaphone() function calculates the metaphone key of a string, this article provides code Farmers introduce the basic usage and examples of the php metaphone() function, which requires...
Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!