PHP - Fonction Ds \ Stack :: count ()

La fonction Ds \ Stack :: count () peut être utilisée pour compter le nombre d'éléments présents dans une pile.

Syntaxe

int Ds\Stack::count( void )

La fonction Ds \ Stack :: count () n'a aucun paramètre.

La fonction Ds \ Stack :: count () peut retourner le nombre de valeurs dans une pile.

Exemple 1

<?php  
   $stack = new \Ds\Stack([1, 4, 5, 7, 9, 10]);  
   var_dump($stack);  
   
   echo "The number of elements present in a stack:";  
   print_r($stack->count());  
?>

Exemple-2

<?php  
   $stack = new \Ds\Stack(["Tutorials", "Point", "India"]);  
   print_r($stack);  
  
   echo "The number of elements present in a stack:";  
   var_dump($stack->count());  
?>