Complete the code to add two numbers and print the result.
<?php $a = 5; $b = 3; $result = $a [1] $b; echo $result; ?>
The plus operator + adds two numbers together.
Complete the code to check if two values are equal.
<?php $x = 10; $y = 10; if ($x [1] $y) { echo 'Equal'; } else { echo 'Not equal'; } ?>
= instead of comparison ==.The double equals == operator checks if two values are equal.
Fix the error in the code to multiply two numbers correctly.
<?php $num1 = 4; $num2 = 7; $product = $num1 [1] $num2; echo $product; ?>
The asterisk * operator multiplies two numbers.
Fill both blanks to create an array of squares for numbers greater than 3.
<?php $numbers = [1, 2, 3, 4, 5]; $squares = array_filter(array_map(fn($n) => $n[1]2, $numbers), fn($n) => $n [2] 9); print_r($squares); ?>
The ** operator raises to a power. The filter keeps squares greater than 9.
Fill all three blanks to create an associative array with keys as uppercase letters and values greater than 2.
<?php $items = ['a' => 1, 'b' => 3, 'c' => 5]; $result = array_filter(array_combine(array_map(fn($k) => [1]($k), array_keys($items)), $items), fn($v) => $v [2] 2 && $v [3] 6); print_r($result); ?>
strtoupper converts keys to uppercase. Values are filtered to be greater than 2 and less than 6.
