Skip to content

Instantly share code, notes, and snippets.

@lloc
Last active March 23, 2018 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloc/239490f2275a2dbc2ee8eef982639867 to your computer and use it in GitHub Desktop.
Save lloc/239490f2275a2dbc2ee8eef982639867 to your computer and use it in GitHub Desktop.
<?php
function variadic_sum( int ... $args ) {
return array_sum( $args );
}
// echoes 6
echo variadic_sum( 1, 2, 3 ), PHP_EOL;
$a = [ 1, 2, 3 ];
$b = [ 4, 5 ];
array_push( $a, ... $b );
// $a contains now [ 1, 2, 3, 4, 5 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment