Home >Backend Development >PHP Tutorial >Use of function extract in php

Use of function extract in php

巴扎黑
巴扎黑Original
2016-12-01 11:53:211463browse

We often encounter extracting the abc index value in the array and paying it to the $abc variable, such as $abc = $_POST['abc'],
This requires such a step. If there are several indexes in $_POST that need to be extracted and paid to the corresponding variables, it will be necessary to write them one by one, which is very troublesome. If you use extract, just

extract($_POST), and then use the variable $abc directly below. The other variables in it are also used in the same way.
Example:

<?php 
$_d[&#39;a&#39;] = &#39;变量a&#39;; 
$_d[&#39;b&#39;] = &#39;变量b&#39;; 
extract($_d); 
echo $a.&#39;-------&#39;.$b; 
?>

Print result:
Variable a--------Variable b

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