Learning PHP and MySQL

Example 06-05 Counting the elements in an array

<?php
$shapes
=array('Soda Can'  =>  'Cylinder',
              
'Note Pad'  =>  'Rectangle',
              
'Apple'  =>  'Sphere',
              
'Orange'  =>  'Sphere',
              
'Phonebook'  =>  'Rectangle');
$numElements  =  count($shapes);
print
"The array has $numElements elements.<br>\n";
?>

Posted by on 08/07 at 10:20 AM

Next entry: Example 06-06 Using sort to alphabetize

Previous entry: Example 06-04 Display the contents of an array using a loop

<< Back to main