PHP Programing language

adplus-dvertising
array_sizeof() and array_count() Function in PHP
Previous Home Next
adplus-dvertising

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