Use of function extract in php

巴扎黑
Release: 2023-03-02 18:48:01
Original
1411 people have browsed it

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

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

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!