Answers for "function passing multiple arguments using 3 dots php"

PHP
0

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
Posted by: Guest on April-19-2021

Code answers related to "function passing multiple arguments using 3 dots php"

Browse Popular Code Answers by Language