function can make our code very simple, recently read a lot of PHP-related knowledge, here to introduce you to the PHP associative array related knowledge. Description International Extract (array $ var_array [abstract $ extract_type = Extr_overwrite [, string $ prefix]]) import variable array into the current symbol table. Check each key to see if it has a valid variable name.
It also checks collisions with existing variable symbol tables, PHP associative arrays. This function takes the key as the variable name and value as the value of the variable. For each key/value pair, a variable is created in the current symbol table, but the extract_type and prefix parameters are required. You must use an associative array, and a numeric index array will not produce results unless you use Extr_prefix_all or Extr_prefix_invalid.
The way invalid/numeric keys and collisions are treated by extract_type. It can be one of the following values:
Extr_overwrite If there is a collision, overwrite the existing variable.
Extr_skip If there is a collision, do not overwrite the existing variable.
Extr_prefix_same If there is a collision, prefix the name of the variable prefixed.
Prefix of all variable names for the Extr_prefix_all prefix.
Extr_prefix_invalid only prefix invalid/numeric prefix of variable name.
Extr_if_exists only overrides the variable if it already exists in the current symbol table, otherwise, nothing is done. It is useful to define the list of valid variables, and then extract only those variables you define the $ _request array.
Extr_prefix_if_exists only creates a prefix variable name if the same variable as the non-prefixed version exists in the current symbol table.
Reference to the Extr_refsextract variable. This actually means that the import of values still refers to the value of the variable, the Var_array parameter. You can use this logo on your own or in conjunction with any other logo or ' ing ' extract_type.
If Extract_type is not specified, this is assumed to be extr_overwrite. Please note that only the prefix is required if Extract_type is Extr_prefix_same, Extr_prefix_all, Extr_prefix_invalid or extr_prefix_if_exists. If the prefix result is not a valid variable name, this is not imported into the symbol table. A prominent feature of the prefix auto-detachment array key. Returns some variables that were successfully imported into the symbol table. Version Description 4.3.0 extr_refs increased. 4.2.0 Extr_if_exists and Extr_prefix_if_exists were added. 4.0.5 This feature now returns some variable extract. Extr_prefix_invalid increased. Extr_prefix_all includes numeric variables as well.
PHP Associative Array instances
Example: Example of a extract object ()
One possible use for extract () is to import into a symbol table variable that contains an associative array that returns Wddx_deserialize ().
- php
- /* Suppose that $var _array are an array returned from
- Wddx_deserialize * *
- $ size = "Large" ;
- $ Var_array = Array ("Color" => "Blue",
- "Size" = > "Medium",
- "Shape" = > "Sphere");
- Extract ($var _array, Extr_prefix_same, "WDDX");
- echo "$color, $size, $shape, $wddx _sizen";
- ?>
http://www.bkjia.com/PHPjc/446488.html www.bkjia.com true http://www.bkjia.com/PHPjc/446488.html techarticle function can make our code very simple, recently read a lot of PHP-related knowledge, here to introduce you to the PHP associative array related knowledge. Description International Extract (array $ var ...