How To Get the Total Number of Values in an Array?

deepak singh
Posts: 686
Joined: Fri Sep 30, 2016 4:19 pm

How To Get the Total Number of Values in an Array?

Postby deepak singh » Sat Oct 01, 2016 5:28 pm

How To Get the Total Number of Values in an Array?

rameshkhd
Posts: 1279
Joined: Sun Aug 28, 2016 10:45 am

Re: How To Get the Total Number of Values in an Array?

Postby rameshkhd » Sat Oct 01, 2016 5:29 pm

You can get the total number of values in an array by using the count() function. Here is a PHP example script:
<?php
$array = array("PHP", "Perl", "Java");
print_r("Size 1: ".count($array)."\n");
$array = array();
print_r("Size 2: ".count($array)."\n");
?>
This script will print:
Size 1: 3
Size 2: 0
Note that count() has an alias called sizeof().


Return to “PHP”

Who is online

Users browsing this forum: No registered users and 4 guests