获取从关联数组键和值和变量赋值
问题描述:
这里是我的数组:获取从关联数组键和值和变量赋值
Array ([username] => john [email] => [email protected] [first_name] => John [last_name] => Bobby)
我怎样才能的一个关键变量分配给每个价值?例如,
$key = $value
所以在这种情况下,这将是:
$username = 'john';
$email = '[email protected]';
etc...
答
可能需要php.extract:http://php.net/manual/en/function.extract.php
$array = ['username' => 'John', ...];
extract($array);
echo $username; // John
otherwise just echo $array['username'] // John