• PHP Video Tutorials

PHP - Ds\Collection::isEmpty()



Ds\Collection::isEmpty() function can return whether the collection is empty.

Syntax

abstract public bool Ds\Collection::isEmpty( void )

Ds\Collection::isEmpty() function doesn't have any parameters. This function can return true if the collection is empty, or false otherwise.

Example-1

<?php 
   $collection = new \Ds\Vector([10, 15, 20, 25, 30, 35]); 
   $res = $collection->isEmpty();
   
   var_dump($res);
   $collection = new \Ds\Vector();
   $res = $collection->isEmpty();
   var_dump($res);  
?>

Example-2

<?php 
   $collection = new \Ds\Vector(); 
   var_dump($collection->isEmpty());
   
   $collection = new \Ds\Vector([1, 3, 5, 2, 6]); 
   var_dump($collection->isEmpty());
?>
php_function_reference.htm
Advertisements