Home > Article > Backend Development > Detailed explanation and example code of PHP array processing function extract
php array processing function extract
extract function is used to import variables from the array into the current symbol table
Basic syntax
int extract (array &$var_array [, int $extract_type = EXTR_OVERWRITE [, string $prefix = NULL ]] )
This function is used to import variables from the array into the current symbol table. Each key name is checked to see if it can be used as a legal variable name, and is also checked for conflicts with existing variable names in the symbol table.
Parameter introduction:
Return value
Returns the number of variables successfully imported into the symbol table.
Example:
<?php $size = "large"; $var_array = array( "color" => "blue", "size" => "medium", "shape" => "sphere" ); extract($var_array, EXTR_PREFIX_SAME, "wddx"); echo " $color , $size , $shape , $wddx_size <br/>"; ?>
Run result:
blue, large, sphere, medium
Thanks Reading, I hope it can help everyone, thank you for your support of this site!
For more detailed explanations and example codes of PHP array processing function extract, please pay attention to the PHP Chinese website!