- Forums
- PHP
- How To Count Elements In An Array Find How Many Values Arrays
This Page Contains information about How To Count Elements In An Array Find How Many Values Arrays By wallpaperama in category PHP with 2 Replies. [1094], Last Updated: Sat May 18, 2024
wallpaperama
Fri Feb 22, 2008
2 Comments
1889 Visits
this is a good php function when you want to know how many elements are in an array.
PHP CODE
<?php
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count($a);
// $result == 3
$b[0] = 7;
$b[5] = 9;
$b[10] = 11;
$result = count($b);
// $result == 3
$result = count(null);
// $result == 0
$result = count(false);
// $result == 1
?>
an easy one is this code also to help you explain how to use this function:
<?
$count = array('1','2','3');
echo '<h1>'.count($count).'</h1>';
?>
OUTPUT: 3
for more information about this function go to http://www.php.net/manual/en/function.count.php
https://www.wallpaperama.com/forums/how-to-count-elements-in-an-array-find-how-many-values-arrays-t5786.html