PHP把数组中的键名作为变量名键值作为变量Author: Lance Ma Date: 2019, 12-27 18:55:47 Category: php 实例方法12345678910111213/** * php 把数组中的键名所为变量名键值作为变量 */$arr=array('a'=>1,'b'=>2,'c'=>3,'d'=>5,'e'=>6); //方法一,使用foreach循环实现 foreach($arr as $key=>$value){ $$key=$value; } echo $a;//方法二,其实php早就已经实现了这个功能extract ,尝试可能会改变源优质类型extract($arr); echo $a;Author: 蓝思同学Permalink: https://www.lancema.com/php/20191227/2020-works-php-ba-shu-zu-zhong-de-jian-ming-zuo-wei-bian-liang-ming-jian-zhi-zuo-wei-bian-liang.htmlSlogan: small is beautiful, small is powerful !Tag(s): # php # 键值 # 变量back · home前后端API接口文档规范 JS获取页面通过URL传的参数