<< More Tips   |   Added On: 15/12/15   |    Category: PHP5    |    Number of Views: 1038

Count the number of elements in a PHP5 array using the count() function

To count the number of elements in a php array we use the php count function.
Copy and paste the code below in to your php file.

<?php
$colours=array("Blue","Red","Green","Orange");
echo "There are ". count($colours) ." elements in this array";
?>

Linux Services

Buy Linux CDs, DVDs, USB Flash Drives from OSDisc.com

Buy Linux CDs, DVDs, USB Flash Drives from OSDisc.com

Run Windows software on Linux

Run Windows software on Linux with Crossover Office