This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Functions

Variable Number of Arguments

Hi, Jane Doe.
Hi, John Doe.
Hi, Joey Doe.

<?php
// there can only be one variable number of arguments and it must be the last
function myFamily($lastname, ...$firstname) {
  $txt = "";
  $len = count($firstname);
  for($i = 0; $i < $len; $i++) {
    $txt = $txt."Hi, $firstname[$i] $lastname.<br>";
  }
  return $txt;
}

// return the values
$a = myFamily("Doe", "Jane", "John", "Joey");
echo $a;
?>