Complete the code to add 2 and 3, then multiply the result by 4.
<?php $result = (2 + 3) [1] 4; echo $result; ?>
The multiplication operator (*) has higher precedence than addition, but parentheses force addition first. So (2 + 3) * 4 equals 20.
Complete the code to check if 5 is greater than 3 and less than 10.
<?php if (5 [1] 3 && 5 < 10) { echo 'True'; } else { echo 'False'; } ?>
The expression 5 > 3 checks if 5 is greater than 3, which is true. Combined with 5 < 10, the whole condition is true.
Fix the error in the expression to correctly calculate 10 minus 3 times 2.
<?php $result = 10 - 3 [1] 2; echo $result; ?>
Multiplication (*) has higher precedence than subtraction (-), so 3 * 2 is calculated first, then subtracted from 10, resulting in 4.
Fill both blanks to create an array with keys as numbers and values as their squares, but only for numbers less than 5.
<?php $squares = []; for ($i = 1; $i <= 6; $i++) if ($i < 5) $squares[[1]] = [2]; print_r($squares); ?>
The key is the number $i, and the value is its square $i * $i. The condition limits to numbers less than 5.
Fill all three blanks to create an associative array with uppercase keys, values as numbers, and only include values greater than 2.
<?php $numbers = [1, 2, 3, 4]; $result = []; foreach ($numbers as [3]) if ([2] > 2) $result[[1]] = [2]; print_r($result); ?>
The key is the uppercase string of the number (strtoupper($num)), the value is the number itself ($num), and the loop variable is $num. The condition filters values greater than 2.