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)- A12% (5)
- B79% (33)
- C2% (1)
- D5% (2)
- E2% (1)
Topics
#floating point precision#array keys#type coercion#count()
Community Discussion
No community discussion yet for this question.