- var_dump: documentation ( source)
- get_defined_vars: documentation ( source)
- array_splice: documentation ( source)
<?php
/*The task is to print out numbers 1 through 100 but for multiples of 3 print out “Fizz” instead of the number and for multiples of 5 print “Buzz” instead. If the number happens to be divisble by both 3 and 5 print out “FizzBuzz” instead of the number.*/
for ($i = 1; $i <= 100; $i++)
{
$Fizz = ($i % 3 === 0);
$Buzz = ($i % 5 === 0);
$FizzBuzz = ($Fizz === true && $Buzz === true);
foreach (array_splice(get_defined_vars(), 0, 2) as $var)
{
var_dump($var);
}
die;
echo $var, PHP_EOL;
}