<?php
function f(){
return [1,2,3,4];
}
list($a,$b,$c,$d) = f();
[$a,$b,$c,$d];
// array(
// 0 => 1,
// 1 => 2,
// 2 => 3,
// 3 => 4
// )
list($x,$y) = f();
[$x,$y];
// array(
// 0 => 1,
// 1 => 2
// )
list(,$m,$n) = f();
[$m,$n];
// array(
// 0 => 2,
// 1 => 3
// )
function g(){
return ['a'=>1];
}
list($a) = g();
// PHP Notice: Undefined offset: 0 in ...
function f(list($a, $b)){
return $a . $b;
}
// PHP Parse error: syntax error, unexpected 'list'