$values = array('value1', 'value2');
$list($v1, $v2) = $values;
[$v1, $v2] = ['foo', 'bar'];
list('v1' => $value1, 'v2' => $value2) = array('v1' => 'foo', 'v2' => 'bar', ...);
// or
['v1' => $value1, 'v2' => $value2] = ['v1' => 'foo', 'v2' => 'bar', ...];
$arr = [
['x', 'y'],
['x1', 'y2'],
];
foreach ($arr as list($x, $y)) {
echo $x, ' ', $y, PHP_EOL;
}
$arr = [
['x' => 1, 'y' => '2'],
['x' => 2, 'y' => '4'],
];
foreach ($arr as ['x' => $x, 'y' => $y)) {
echo $x, ' ', $y, PHP_EOL;
}
class ElePHPant
{
private $name, $colour, $age, $cuteness;
public function __construct(array $attributes) {
// $this->name = $attributes['name']; // 以前
// 现在
[
"name" => $this->name,
"colour" => $this->colour,
"age" => $this->age,
"cuteness" => $this->cuteness
] = $attributes;
}
// ...
}
[[$a, $b], [$c, $d]] = [[1, 2], [3, 4]];
class ElePHPant
{
private $name, $colour, $age, $cuteness;
public function __construct(["name" => string $name, "colour" => \Colour $colour, "age" => int $age, "cuteness" => float $cuteness]) {
$this->name = $name;
$this->colour = $colour;
$this->age = $age;
$this->cuteness = $cuteness;
}
// ...
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有