1. Home
  2. Computer Science MCQs
  3. PHP
  4. PHP’s numerically indexed array begin with position __.

Added 19 Jan 2024

PHP’s numerically indexed array begin with position __.

  1. 1
  2. 2
  3. 0 Correct answer
  4. -1

Correct answer

C. 0

14 views

MCQSEXAM

Explanation

Numerically indexed arrays in PHP begin at position 0. So in $a = array("x", "y", "z"), $a[0] is "x" and the last element is at index 2.

Zero-based indexing is shared with C, Java and JavaScript, and forgetting it is the classic cause of off-by-one errors in loops.

Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs