Phpmetaphone () function and phplocaleconv () function instance parser _ php instance

Source: Internet
Author: User
This article mainly introduces phpmetaphone () function and phplocaleconv () function instance parsing related information. For more information, see the metaphone key of the php metaphone () function compute string, this article introduces the basic usage and examples of php metaphone () functions to coders. For the coders, refer to the methods and examples in this article.

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

The Code is as follows:


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";$str = "Assistants";echo metaphone($str);echo "
";echo metaphone($str);?>

Example 2

Use the length parameter:

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

So much about the parsing of php metaphone () functions.

The following describes how to parse a php localeconv () function instance. The details are as follows:

The php localeconv () function returns an array containing local numbers and currency format information. This article introduces the usage and basic instances of the php localeconv () function to the coders. For more information about the coders, see.

Definition and usage

The localeconv () function returns an array containing local numbers and currency format information.

The localeconv () function returns the following array elements:

[Decimal_point]-decimal point character
[Thousands_sep]-thousands Separator
[Int_curr_symbol]-currency symbol (for example, USD)
[Currency_symbol]-currency symbol (for example, $)
[Mon_decimal_point]-decimal point character in currency
[Mon_thousands_sep]-currency thousands Separator
[Positive_sign]-positive character
[Negative_sign]-negative value character
[Int_frac_digits]-universal international scale
[Frac_digits]-general local decimal places
[P_cs_precedes]-If the currency symbol is displayed before a positive value, it is True (1). If it is displayed after a positive value, it is False (0)
[P_sep_by_space]-if there is a space between the currency symbol and the positive value, True (1); otherwise, False (0)
[N_cs_precedes]-If the currency symbol is displayed before a negative value, it is True (1). If it is displayed after a negative value, it is False (0)
[N_sep_by_space]-True (1) If there is a space between the currency symbol and the negative value; otherwise, False (0)
[P_sign_posn]-formatting options:
0-write the number and currency symbols in parentheses
1-Add a plus sign before the number and currency symbol
2-Add the plus sign after the number and currency symbol
3-Add a plus sign directly before the currency symbol
4-Add a plus sign directly after the currency symbol
[N_sign_posn]-formatting options:
0-write the number and currency symbols in parentheses
1-Add the minus sign before the number and currency symbol
2-Add the minus sign after the number and currency symbol
3-Add the minus sign directly before the currency symbol
4-Add the minus sign directly after the currency symbol
[Grouping]-displays arrays in the form of a combination of numbers (for example, 3 indicates 1 000 000)
[Mon_grouping]-displays an array in the form of a combination of currency numbers (for example, 2 indicates 1 00 00)

Tip: To define local settings, see setlocale () function.

Tip: If you need to refer to all available language codes, please visit our language code reference manual.

Syntax

The Code is as follows:


Localeconv ()

Technical details

Return Value: Returns the current local data set by setlocale.
PHP version: 4.0.5 +

Instance

Find the number formatting information in the United States:

<?phpsetlocale(LC_ALL,"US");$locale_info = localeconv();print_r($locale_info);?>

The above section describes how to parse the php metaphone () function and the php localeconv () function instance. I hope it will help you!

Related Article

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.