php function with 2 parameters code example
Example 1: function passing multiple arguments using 3 dots php
function concatenate($transform, ...$strings) {
$string = '';
foreach($strings as $piece) {
$string .= $piece;
}
return($transform($string));
}
echo concatenate("strtoupper", "I'd ", "like ", 4 + 2, " apples");
// This would print:
// I'D LIKE 6 APPLES
Example 2: variable args php
function some_function(...$args): void {
$val1 = $args[0];
// Access as normal index array
}