English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The extract() function imports variables from an array into the current symbol table
extract($array, $extract_type, $prefix)
This function is used to import variables from an array into the current symbol table. It takes an associated array array, and treats the keys as variable names and the values as variable values. For each key/A value pair, it will create a variable in the current symbol table, constrained by the extract_type and prefix parameters.
Serial Number | Parameters and Description |
---|---|
1 | array (required) It specifies an array |
2 | extract_type (optional) The extract() function checks invalid variable names and conflicts with existing variable names. This parameter specifies how to handle invalid names and conflict names. Possible values:
|
3 | prefix (optional) If EXTR_PREFIX_SAME, EXTR_PREFIX_ALL, EXTR_PREFIX_INVALID, or EXTR_PREFIX_IF_EXISTS is used in the extract_rules parameter, the specified prefix is required. This parameter specifies the prefix. The prefix is automatically separated from the array key by an underscore character. |
Returns the number of variables successfully imported into the symbol table.
"blue", "size" => "medium", "shape" => "sphere"); extract(\$input, EXTR_PREFIX_SAME, "bbcx"); echo "\$color, \$size, \$shape, \$bbcx_size"; ?>Test and see‹/›
Output Result:
blue, large, sphere, medium