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

Detailed explanation and example code of PHP array processing function extract

高洛峰
Release: 2023-03-04 13:04:01
Original
1327 people have browsed it

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/>";
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template