Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q14 of 15
PHP - Arrays
Find the error in this code snippet:
$arr = [[1, 2], [3, 4];
echo $arr[1][1];
AMissing closing bracket for the first array
BMissing closing bracket for the outer array
CIncorrect index used to access element
DMissing semicolon after echo statement
Step-by-Step Solution
Solution:
  1. Step 1: Check array syntax

    The array starts with [[ but only one closing bracket ] is present before the semicolon.
  2. Step 2: Identify missing bracket

    The outer array requires a closing bracket ], so the code should end with ]];
  3. Final Answer:

    Missing closing bracket for the outer array -> Option B
  4. Quick Check:

    Outer array brackets must match [OK]
Quick Trick: Count opening and closing brackets carefully [OK]
Common Mistakes:
  • Confusing inner and outer brackets
  • Ignoring syntax errors
  • Assuming semicolon fixes bracket issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes