配列の中の要素の数を取得するには、sizeof関数、もしくはcount関数を使う。

どうやらどちらでも同じっぽい。

$shapes = array('Soda can' => 'Cylinder',
 'Notepad' => 'Rectangle',
 'Apple' => 'Sphere',
 'Phonebook' => 'Rectangle');
$numElements = count($shapes);
$numElements2 = sizeof($shapes);
print "The array has $numElements elements.<br />";
print "The array has $numElements2 elements.<br />";
?>

上記のコードをブラウザで表示させると、

The array has 4 elements.
The array has 4 elements.

と、変数$numElementsも、変数$numElements2も、両方4が格納されている。