Complete the code to print the value of the variable.
<?php $counter = 5; echo [1]; ?>
The variable $counter holds the value 5. To print it, use echo $counter;.
Complete the code to reset the variable $count to zero.
<?php $count = 10; $count = [1]; echo $count; ?>
null instead of zero.To reset a numeric variable to zero, assign 0 to it.
Fix the error in the code to correctly unset the variable $temp.
<?php $temp = 100; [1]($temp); echo isset($temp) ? 'Exists' : 'Unset'; ?>
delete or remove.In PHP, unset() is used to delete a variable from memory.
Fill both blanks to create an array with keys as numbers and values as their squares, but only for numbers greater than 3.
<?php $numbers = range(1, 5); $squares = array_combine(array_filter($numbers, function($n) { return $n [2] 3; }), array_map(function($n) { return $n[1]2; }, array_filter($numbers, function($n) { return $n [2] 3; })); print_r($squares); ?>
+ instead of power operator.< instead of > in condition.The ** operator calculates powers in PHP. The condition $n > 3 filters numbers greater than 3.
Fill all three blanks to create an associative array with uppercase keys and values greater than zero.
<?php $data = ['a' => 1, 'b' => -2, 'c' => 3]; $result = array_filter(array_combine(array_map(function($k) { return [1]; }, array_keys($data)), [3]), function($v) { return $v [2] 0; }); print_r($result); ?>
array_keys($data) instead of values for filtering.< instead of > in condition.strtoupper($k) converts keys to uppercase. The condition > 0 filters positive values. array_values($data) provides the values for filtering.