Skip to content

Instantly share code, notes, and snippets.

@chalasr
Last active April 11, 2016 13:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chalasr/9545848ee69722c6813f to your computer and use it in GitHub Desktop.
Save chalasr/9545848ee69722c6813f to your computer and use it in GitHub Desktop.
function with dynamic number of type-hinted arguments using the splat operator PHP 5.6
<?php
function splat(array ...$args) {
foreach ($args as $arg) {
print_r($arg);
}
}
splat(['firstArray'], ['secondArray']);
// Output: Array( [0] => firstArray ) Array( [0] => secondArray )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment