+ 3

A question about count in Php

I have noticed in the challenge that: echo count(array(true=>1,false=>2,0=>3,1=>4)); gives 2. I think count does counts the keys, because true is 1 and false is 0, it gives 0. Am I right, inshaALLAH?

1st Aug 2019, 11:18 AM
Yusuf
Yusuf - avatar
1 Resposta
0
Yusuf , it's because old values for the same keys are replaced with the new ones (as you mentioned there are duplicate keys (0 and false and 1 and true). Finally associative array is (1=>4, 0=>3). https://code.sololearn.com/wZk5bgQ8ZvaC/?ref=app
1st Aug 2019, 11:55 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar