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

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.