PHP | Ds\Collection isEmpty() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The Ds\Collection::isEmpty() function is an inbuilt function in PHP which is used to returns whether collection is empty. Syntax: Ds\Collection::isEmpty ( void ) : bool Parameters: This function does not accepts any parameters. Return Value: It returns True if collection is empty or False otherwise. Below programs illustrate the Ds\Collection::isEmpty() function in PHP: Example 1: php <?php // Create a collection $collection = new \Ds\Vector([10, 15, 21, 13, 16, 18]); // Use isEmpty function $res = $collection->isEmpty(); // Display the result var_dump($res); // Create a collection $collection = new \Ds\Vector(); // Use isEmpty function $res = $collection->isEmpty(); // Display the result var_dump($res); ?> Output: bool(false) bool(true) Example 2: php <?php // Create a collection $collection = new \Ds\Vector(); // display output var_dump($collection->isEmpty()); // Create a collection $collection = new \Ds\Vector([1, 3, 5, 2, 6]); // Display output var_dump($collection->isEmpty()); ?> Output: bool(true) bool(false) Reference: https://www.php.net/manual/en/ds-collection.isempty.php Create Quiz Comment V vijay_raj Follow 0 Improve V vijay_raj Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP-DS\Collection Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like