function asdf(){
$a1 = [1,2,3];
$a2 = [3,4,5];
$a = array(
"x" => $a1,
"y" => $a2
);
return $a;
}
是否可以使用foreach执行此操作? :
$a = $this->asdf();
$x = $a['x']; $y = $a['y];
答案 0 :(得分:0)
考虑到这一点被认为是不好的做法,因为这会使您的代码无法读取。
UI
输出:
function asdf(){
$a1 = [1,2,3];
$a2 = [3,4,5];
$a = array(
"x" => $a1,
"y" => $a2
);
return $a;
}
$a = asdf();
foreach($a as $index => $value){
$$index = $value;
}
var_dump($x);
var_dump($y);