<?php
$arr = [1,2,3,4,5];
function test(int $a, int $b, int $c, int $d , int $e) {
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
var_dump($e);
}
// 配列がアンパックされて各要素が引数に渡される
test(...$arr);
// 実行すると以下のアウトプットが出る
// int(1)
// int(2)
// int(3)
// int(4)
// int(5)
?>
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
44