PHP Metaphone () function and PHP localeconv () function instance Parse _php instance

Source: Internet
Author: User
Tags define local locale

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.

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

Grammar

Copy Code code as follows:

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 = "assistants";
Echo Metaphone ($STR);
echo "<br>";
Echo Metaphone ($STR);
? >

Example 2

Use length parameter:

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

About PHP Metaphone () function parsing to introduce you so much.

Here is an introduction to the PHP Localeconv () Function instance resolution, details are as follows:

The PHP localeconv () function returns an array containing both local and currency format information. This article introduces the use method and basic example of PHP localeconv () function to code agriculture. Need the Code farmers can refer to.

Definitions and usage

The Localeconv () function returns an array containing both local and currency format information.

The Localeconv () function returns the following array element:

[Decimal_point]-Decimal characters
[thousands_sep]-thousand separator
[int_curr_symbol]-Currency symbol (for example: USD)
[currency_symbol]-Currency symbol (For example: $)
[mon_decimal_point]-Currency decimal character
[mon_thousands_sep]-Currency thousand separator
[positive_sign]-positive character
[negative_sign ]-Negative characters
[int_frac_digits]-International decimal places
[frac_digits]-Local Universal decimal places
[P_cs_precedes]-true if the currency symbol is displayed before a positive value (1), if the A positive value is displayed, False (0)
[P_sep_by_space]-True (1) If there is a space between the currency symbol and the positive value, or False (0)
[n_cs_precedes]- True (1) If the currency symbol appears before a negative value, or False (0)
[n_sep_by_space] If a negative value is displayed-if a space is between the currency symbol and the negative value, true (1), or False (0)
[P_sign_posn]-formatting options:
0-Write the number and currency symbols in parentheses
1-add + before the number and currency symbol
2-Add the + sign after the number and currency symbol
3-directly before the currency symbol Plus + Number
4-directly after the currency symbol plus the + number
[N_sign_posn]-formatting options:
0-write numbers and currency symbols in parentheses
1-precede the number and currency symbols with the-number
2-After the number and currency symbol plus -Number
3-precede the currency symbol with the-number
4-directly after the currency symbol plus-number
[grouping]-displays an array of numeric combinations (for example: 3 indicates 1)
[mon_grouping]- Displays an array of currency number combinations (for example: 2 instruction 1)

Tip: If you want to define local settings, see the setlocale () function.

Tip: To refer to all available language codes, please visit our Language Code reference manual.

Grammar

Copy Code code as follows:

Localeconv ()

Technical details

return value: Returns the current local data based on the setlocale () setting.
PHP version: 4.0.5+

Instance

Find local digital formatting information in the United States:

<?php
setlocale (lc_all, "US");
$locale _info = Localeconv ();
Print_r ($locale _info);
? >

The above is described in this article for you to introduce PHP Metaphone () function and PHP localeconv () Function example analysis, I hope to help!

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.