Phpmetaphone () function definition and usage, phpmetaphone_PHP tutorial

Source: Internet
Author: User
Phpmetaphone () function definition and usage, phpmetaphone. Phpmetaphone () function definition and usage, phpmetaphonephpmetaphone () function compute string metaphone key, this article introduces the phpmetaphone () function basic usage and real php metaphone () function definition and usage, phpmetaphone

The metaphone key of the php metaphone () function compute string. This article introduces the basic usage and example of the php metaphone () function to the coders, you can refer to the methods and examples in this article for the necessary coders.

Definition and usage

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

Metaphone indicates the English pronunciation of a string.

The metaphone () function can be used by spelling check programs.

Note: The metaphone () function creates the same key for words with similar pronunciation.

Note: the length of the generated metaphone key is variable.

Tip: metaphone () is more accurate than soundex (), because metaphone () understands basic English pronunciation rules.

Syntax

Metaphone (string, length)
  
Parameters Description
String Required. Specifies the string to be checked.
Length Optional. Specifies the maximum length of the metaphone key.

Technical details

Return value: If the call succeeds, the metaphone key of the string is returned. if the call fails, FALSE is returned.
PHP version: 4 +

Instance

Example 1

Use the metaphone () function for two words with similar pronunciation:

<?php $str = "Assistance"; $str2 = "Assistants";  echo metaphone($str); echo "
"; echo metaphone($str2); ?>

Example 2

Use the length parameter:

<?php $str = "Assistance"; $str2 = "Assistants";  echo metaphone($str,5); echo "
"; echo metaphone($str2,5); ?>

The definition and usage of the above php metaphone () function is all the content that I share with you. I hope you can give me a reference and support me a lot.

Http://www.bkjia.com/PHPjc/1127893.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1127893.htmlTechArticlephp metaphone () function definition and usage, phpmetaphone php metaphone () function compute string metaphone key, this article introduces php metaphone () to coders () basic usage and implementation of functions...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.