PHP Programing language

array_sizeof() and array_count() Function in PHP
Previous Home Next

array_sizeof()

The sizeof() function returns the number of elements in an array.

Syntax:
sizeof(array,mode);

In above syntax, "array" specifies the array, "mode" specifies the mode and values are as follows:

  • 0: Default. Does not count all elements of multidimensional arrays
  • 1: Counts the array recursively (counts all the elements of multidimensional arrays)

Example:

<?php
$fruits=array("Apple","Mango","Orange","Banana");
echo sizeof($fruits);
?>

 

Output:

4

array_count()

The count() function returns the number of elements in an array.

Syntax:
pre> count(array,mode);

In above syntax, "array" specifies the array, "mode" specifies the mode and values are as follows:

  • 0: Default. Does not count all elements of multidimensional arrays
  • 1: Counts the array recursively (counts all the elements of multidimensional arrays)

Example:

<?php
$fruits=array("Apple","Mango","Orange","Banana");
echo count($fruits);
?>

Output:

4

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: