Skip to content

Instantly share code, notes, and snippets.

@Chemaclass
Created September 21, 2019 22:51
Show Gist options
  • Select an option

  • Save Chemaclass/1a39db3954e0be006b370e8c2bd0e587 to your computer and use it in GitHub Desktop.

Select an option

Save Chemaclass/1a39db3954e0be006b370e8c2bd0e587 to your computer and use it in GitHub Desktop.
Docu - Return type declarations
<?php
function arraysSum(array ...$arrays): array
{
return array_map(function(array $array): int {
return array_sum($array);
}, $arrays);
}
print_r(arraysSum([1,2,3], [4,5,6], [7,8,9]));
?>
// outputs:
Array
(
[0] => 6
[1] => 15
[2] => 24
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment