Bird
0
0

Why do PHP arrays allow keys of different types (integers and strings)?

hard📝 Conceptual Q10 of 15
PHP - Arrays
Why do PHP arrays allow keys of different types (integers and strings)?
ATo provide flexibility in storing data with meaningful keys
BBecause PHP does not support integers
CTo make arrays slower
DBecause keys must always be strings
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP array keys

    PHP arrays can have keys as integers or strings to allow flexible data labeling.
  2. Step 2: Evaluate options

    To provide flexibility in storing data with meaningful keys explains this flexibility; others are incorrect or false.
  3. Final Answer:

    To provide flexibility in storing data with meaningful keys -> Option A
  4. Quick Check:

    Flexible keys = C [OK]
Quick Trick: Arrays accept int and string keys for flexibility [OK]
Common Mistakes:
  • Thinking keys must be only strings
  • Believing PHP lacks integer support
  • Assuming mixed keys slow arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes