Bird
0
0

Find the error in this PHP associative array creation:

medium📝 Debug Q7 of 15
PHP - Arrays
Find the error in this PHP associative array creation:
$arr = array("name" => "Alice" "age" => 25);
AKeys must be integers
BUsing array() instead of []
CMissing comma between elements
DValues must be strings
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax between key-value pairs

    Pairs must be separated by commas.
  2. Step 2: Identify missing comma between "name" and "age" pairs

    There is no comma after "Alice".
  3. Final Answer:

    Missing comma between elements -> Option C
  4. Quick Check:

    Separate pairs with commas [OK]
Quick Trick: Always separate key-value pairs with commas [OK]
Common Mistakes:
  • Forgetting commas
  • Wrong brackets
  • Invalid keys or values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes