Counting the elements in an array : const « Class « PHP






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 />";
?>
  
  








Related examples in the same category

1.Constant definition is considered a static member of the class
2.Finding the size of an array
3.Using Class Constants
4.Using Class Constants in PHP5