如何将数组的值放在具有相同名称的变量中

时间:2012-01-10 06:45:54

标签: php arrays

我写了一些代码:

$params = func_get_args();
$title = $params[1]['title'];
$writer = $params[1]['writer'];
$magname = $params[1]['magname'];
$confname = $params[1]['confname'];
$magyear = $params[1]['magyear'];
$confyear = $params[1]['confyear'];
$subject = $params[1]['subject'];
$scredit = $params[1]['scredit'];
$lang = $params[1]['lang'];
$keywords = $params[1]['keywords'];
$pyear = $params[1]['pyear'];
.....

是否可以使用循环执行此操作?

1 个答案:

答案 0 :(得分:3)

这应该这样做:

extract($params[1]);