PHP- count() Function

PHP count() Function

(PHP 4, PHP 5, PHP 7, PHP 8)
count() function — Count all elements in an array, or something in an object


Syntax

Syntax for count() function:


count ( Countable|array $value , int $mode = COUNT_NORMAL ) : int

Parameters

Value

An array or Countable object.

mode

If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count() will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array.


Get The Length of an Array - The count() Function

<?php
$names = array("Looper", "Cabdi", "Shwe");
echo count($names);
?>

Post a Comment

Previous Post Next Post