The definition and usage of PHP metaphone () function _php instance

Source: Internet
Author: User
Tags function definition

PHP Metaphone () function to compute the Metaphone key of the string, this article introduces the basic usage and example of PHP Metaphone () function to the code farmers, the code farmers need to refer to the method and examples of this article.

Definitions and usage

The Metaphone () function evaluates the Metaphone key of the string.

The Metaphone key represents the English pronunciation of the string.

The Metaphone () function can be used for the spelling checker.

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

Note: The generated metaphone keys are variable in length.

Hint: Metaphone () is more accurate than the SOUNDEX () function because Metaphone () understands the basic rules of English pronunciation.

Grammar

Metaphone (String,length)
  
Parameters Description
String Necessary. Specify the string to check.
Length Optional. Specify the maximum length of the Metaphone key.

Technical details

return value: Returns the Metaphone key of the string if successful, FALSE if it fails.
PHP version: 4 +

Instance

Example 1

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

<?php 
$str = "Assistance"; 
$str 2 = "assistants"; 
 
Echo Metaphone ($STR); 
echo "<br>"; 
Echo Metaphone ($str 2); 
? > 

Example 2

Use length parameter:

<?php 
$str = "Assistance"; 
$str 2 = "assistants"; 
 
Echo Metaphone ($STR, 5); 
echo "<br>"; 
Echo Metaphone ($str 2,5); 
? > 

The above PHP metaphone () function definition and usage is small series to share all the content, hope to give everyone a reference, also hope that we support cloud habitat community.

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.