Extract function _php Tutorial in PHP

Source: Internet
Author: User
The extract function is used to decompose a number into multiple variables directly, and the following is the explanation of the user: the PHP extract () function imports variables from the array into the current symbol table. For each element in the array, the key name is used for the variable name, and the key value is used for the variable value. The second parameter type is used to specify how the extract () function treats conflicts when a variable already exists and the element with the same name in the array. This function returns the number of variables that were set successfully. The following table is a parameter description: syntax extract (array,extract_rules,prefix) parameter Description array Necessary. Specifies the input to use. Extract_rules 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 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. This is useful when getting a row of data from a database, let's take a look at the following example copy code <title><?php Echo Ucfirst ($_get[' action ');? > Movie</title> Copy code note the Red statement, after using extract can be used directly after the variable, and the name of the variable is the field name, the value of the variable is the value of the field, which is somewhat similar to the method of obtaining data from the DataReader or dataset in ADO Movie.name = Dataset.table[o]. row[i]["Name"]. ToString () movie.name=reader["Name"]. ToString ();

http://www.bkjia.com/PHPjc/766055.html www.bkjia.com true http://www.bkjia.com/PHPjc/766055.html techarticle The extract function is used to decompose a number into multiple variables directly, and the following is the explanation of the user: the PHP extract () function imports variables from the array into the current symbol table. For the array ...

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