Open In App

PHP | Ds\Stack count() Function

Last Updated : 30 Jul, 2019
Comments
Improve
Suggest changes
1 Like
Like
Report
The Ds\Stack::count() function is an inbuilt function in PHP which is used to count the number of elements present in the Stack. Syntax:
int Ds\Stack::count( void )
Parameters: This function does not accept any parameter. Return Value: This function returns the number of elements present in the Stack. Below programs illustrate the Ds\Stack::count() function in PHP: Program 1:
Output:
object(Ds\Stack)#1 (3) {
  [0]=>
  int(21)
  [1]=>
  int(15)
  [2]=>
  int(10)
}
Number of elements present in the stack: 3
Program 2:
Output:
Ds\Stack Object
(
    [0] => Keegs
    [1] => for
    [2] => Geeks
)
Number of elements present in the stack: int(3)
Reference: https://www.php.net/manual/en/ds-stack.count.php

Next Article

Similar Reads