PHP Count function with Associative Array
问题 Could someone please explain to me how the count function works with arrays like the one below? My thought would be the following code to output 4, cause there are 4 elements there: $a = array ( "1" => "A", 1=> "B", "C", 2 =>"D" ); echo count($a); 回答1: 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" is equal to 1, so 1 => "B" will overwrite "1" => "A" . because you