Mega Code Archive

 
Categories / Php / Class
 

Counting the elements in an array

<?php $shapes = array('S' => 'Cylinder',                 'N' => 'Rectangle',                 'A' => 'Sphere',                 'O' => 'Sphere',                 'P' => 'Rectangle'); $numElements = count($shapes); print "The array has $numElements elements.<br />"; ?>