拆分一个数组在PHP中的变量 [英] Splitting an array into the variables in php

查看:172
本文介绍了拆分一个数组在PHP中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个数组,$ display_vars,我想将它拆分成独立的变量,因此每个变量的名称是数组键,它的值是值,可以这么说。因此,如果数组是这样的:

I have this array, $display_vars, and I want to split it into separate variables, so each variable's name is the array key, and it's value is the value, so to speak. So if the array was like this:

$display_vars = array(
'title' => 'something',
'header' => 'something else'
);

然后我想这相当于结束:

Then I want to end up with the equivalent of this:

$title = 'something';
$header = 'something else';

你能想到什么办法都不可能做到这一点?

Can you think of any way I can possibly do this?

推荐答案

提取物 功能正是这一点。

The extract function does exactly this.

看到它在行动 (包括奖金参照 get_defined_vars )。

这篇关于拆分一个数组在PHP中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆