Home  >  Article  >  Backend Development  >  Detailed explanation and example code of PHP array processing function extract

Detailed explanation and example code of PHP array processing function extract

高洛峰
高洛峰Original
2016-12-30 10:54:071263browse

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:

php 数组处理函数extract详解及实例代码

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn