About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Counting Arrays...

   Browse by title articles:
   What is hot:

for loops

Arrays Intro

Creating/Accessing Arrays

Adding/Replacing Arrays

Merging Arrays

Counting Arrays

Variables
Hard Drive Does Not Boot
Web Site Management: Guestbooks
Picking the Right Font Face for your Document
Prev articles1234567 8 9101112Next articles



Counting Arrays


Computer & I'net articlesCounting Arrays

by David Stanley    



Counting the number of elements in an array uses a command called count.

First we will start with our original pantry array :

<?php
$pantry = array(
   1 => "apples",
   2 => "oranges",
   3 => "bananas"
   );
?>

Now to count how many elements are in this array...

<?php
$total_elements = count($pantry);
echo "There are $total_elements elements in the array.";
?>

This will produce the result :
There are 3 elements in the array.



-----------------
Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.





Savings Estimator




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com