function passing multiple arguments using 3 dots php

Solutions on MaxInterview for function passing multiple arguments using 3 dots php by the best coders in the world

showing results for - "function passing multiple arguments using 3 dots php"
Isabelle
20 Nov 2019
1function concatenate($transform, ...$strings) {
2    $string = '';
3    foreach($strings as $piece) {
4        $string .= $piece;
5    }
6    return($transform($string));
7}
8
9echo concatenate("strtoupper", "I'd ", "like ", 4 + 2, " apples");
10// This would print:
11// I'D LIKE 6 APPLES
12