nerdexam
Zend

200-710 · Question #181

What is the output of the following code? ``php for ($i = 0; $i < 1.02; $i += 0.1?) { $a[$i] = $i; } echo count ($a); ``

The correct answer is B. 1. See the full explanation below for the reasoning.

Arrays

Question

What is the output of the following code?
for ($i = 0; $i < 1.02; $i += 0.1?) {
 $a[$i] = $i;
}
echo count ($a);

Options

  • A0
  • B1
  • C2
  • D6
  • E7

How the community answered

(42 responses)
  • A
    12% (5)
  • B
    79% (33)
  • C
    2% (1)
  • D
    5% (2)
  • E
    2% (1)

Topics

#floating point precision#array keys#type coercion#count()

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice