Skip to content
Related Articles

Related Articles

Improve Article
PHP | ArrayIterator count() Function
  • Last Updated : 21 Nov, 2019

The ArrayIterator::count() function is an inbuilt function in PHP which is used to count the elements of array iterator.

Syntax:

int ArrayIterator::count( void )

Parameters: This function does not accept any parameters.

Return Value: This function returns the number of element present in the array iterator.

Below programs illustrate the ArrayIterator::count() functio in PHP:



Program 1:




<?php
   
// Declare an ArrayIterator
$arrItr = new ArrayIterator(
    array('G', 'e', 'e', 'k', 's')
);
   
// Count the element into array iterator
echo $arrItr->count();
   
?>
Output:
5

Program 2:




<?php
   
// Declare an ArrayIterator
$arrItr = new ArrayIterator(
    array("Geeks", "for", "Geeks"), 
    ArrayIterator::STD_PROP_LIST
);
   
// Count the array element
echo $arrItr->count();
   
?>
Output:
3

Reference: https://www.php.net/manual/en/arrayiterator.count.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :