The function of distributing the array key value in PHP into variable name and value extract detailed

Source: Internet
Author: User
The function of the PHP extract () function is to distribute the array key values as functions of variables and values extract detailed.

Extract (Array,extract_rules,prefix)

Array required.

Specifies the input to use.

Extract_rules is optional.

The extract () function checks to see if each key name is a valid variable name, and also checks whether the variable names in the symbol table conflict. The handling of illegal, numeric, and conflicting key names is determined by this parameter. Can be one of the following values: Possible values:

Extr_overwrite-Default. If there is a conflict, overwrite the existing variable.

Extr_skip-If there is a conflict, do not overwrite the existing variable. (ignores elements with the same name in the array)

Extr_prefix_same-If there is a conflict, precede the variable name with the prefix PREFIX. Since PHP 4.0.5, this also includes the processing of the digital index.

Extr_prefix_all-Prefix all variable names with PREFIX (the third argument).

Extr_prefix_invalid-prefix PREFIX only before illegal or numeric variable names. This tag is a new addition to PHP 4.0.5.

Extr_if_exists-Overrides the value of a variable with the same name in the current symbol table only. None of the others will deal with it. It can be used where a set of valid variables has been defined and then extracted from an array such as $_request to override those variables. This tag is a new addition to PHP 4.2.0.

Extr_prefix_if_exists-A variable name with the prefix appended to it is created only if a variable with the same name already exists in the current symbol table, and none of the others are processed. This tag is a new addition to PHP 4.2.0.

Extr_refs-Extracts the variable as a reference. This strongly demonstrates that the imported variable still references the value of the Var_array parameter. This flag can be used alone or in conjunction with any other flag in Extract_type. This tag is a new addition to PHP 4.3.0.

prefix is optional.

Note that prefix is required only if the value of Extract_type is Extr_prefix_same,extr_prefix_all,extr_prefix_invalid or extr_prefix_if_exists. If the result appended with the prefix is not a valid variable name, it will not be imported into the symbol table. An underscore is automatically added between the prefix and the array key name.

  • 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.