Complete the code to add two numbers and print the result.
<?php $a = 5; $b = 3; $result = $a [1] $b; echo $result; ?>
- instead of plus +.The plus sign + adds two numbers together.
Complete the code to multiply two numbers and print the result.
<?php $x = 7; $y = 4; $product = $x [1] $y; echo $product; ?>
+ instead of multiplication *.The asterisk * multiplies two numbers.
Fix the error in the code to correctly divide two numbers and print the result.
<?php $num1 = 10; $num2 = 2; $division = $num1 [1] $num2; echo $division; ?>
- or multiplication * instead of division /.The forward slash / divides one number by another.
Fill both blanks to create a dictionary of squares for numbers greater than 3.
<?php $numbers = [1, 2, 3, 4, 5]; $squares = []; foreach ($numbers as $num) { if ($num [1] 3) { $squares[$num] = $num [2] 2; } } print_r($squares); ?>
< instead of greater than >.* instead of power ** for squaring.The operator > checks if a number is greater than 3. The operator ** raises the number to the power of 2 (square).
Fill all three blanks to create an array of numbers and filter those divisible by 2.
<?php $numbers = range(1, 10); $evens = []; foreach ($numbers as [1]) { if ([2] % 2 [3] 0) { $evens[] = [2]; } } print_r($evens); ?>
$ sign.!= instead of equal ==.The variable $num is used to loop through numbers. The operator == checks if the remainder is zero, meaning the number is divisible by 2.
