count() in php

Saturday, November 8, 2008 11:29
Posted in category PHP, Programming

The count() function is useful when you want to return how many elements are in your array. You can then use this in a for loop. Here’s an example we used earlier, only this time with the count function:

$a[0]  = 2;
$a[5]  = 3;
$a[10] = 6;
$totalsize = count($a);

for($i=o;$i< $totalsize;$i++){

echo $totalsize[$i];

}

You can leave a response, or trackback from your own site.

Leave a Reply