18
count works exactly as you would expect, e.g., it counts all the elements in an array (or object). But your assumption about the array containing four elements is wrong:
1 => "B" will overwrite "1" => "A".2 => "C"2 => "D" you overwrote "C".So your array will only contain 1 => "B" and 2 => "D" and that's why count gives 2. You can verify this is true by doing print_r($a). This will give
Array
(
[1] => B
[2] => D
)
Please go through Arrays again.