ফাংশনের আর্গুমেন্ট এমনভাবে নির্দিষ্ট করা যায় যাতে এটি যেকোনো সংখ্যক আর্গুমেন্ট নিতে পারে:
<?php
function actOnItems(...$items) {
// $items is an array containing 0 or more values
// used to call the function.
}
actOnItems(1, 2, 3, 4); // $items => [1, 2, 3, 4]
অন্য আর্গুমেন্টের পাশাপাশি একটি ভ্যারিয়েবল-দৈর্ঘ্যের আর্গুমেন্ট নির্দিষ্ট করলে, সেটি অবশ্যই শেষ আর্গুমেন্ট হতে হবে।
<?php
function writeLines($file_handle, ...$lines)
{
put_file_contents($file_handle, implode("\n", $lines));
}
writeLines('file.txt', "a", "b", "c");