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

29

<?php
// Variable Number of Arguments
function sumMyNumbers(...$x) {
  $n = 0;
  $len = count($x);
  for($i = 0; $i < $len; $i++) {
    $n += $x[$i];
  }
  return $n;
}

// return the results
$a = sumMyNumbers(5, 2, 6, 2, 7, 7);
echo $a;
?>