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 // 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 // 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: http://php.net/manual/en/ds-collection.isempty.php
Recommended Posts:
- PHP | Ds\Deque isEmpty() Function
- PHP | Ds\Map isEmpty() Function
- PHP | Ds\Vector isEmpty() Function
- PHP | Ds\Stack isEmpty() Function
- PHP Ds\PriorityQueue isEmpty() Function
- PHP Ds\Queue isEmpty() Function
- PHP Ds\Set isEmpty() Function
- PHP | SplDoublyLinkedList isEmpty() Function
- Underscore.js | _.isEmpty()
- Lodash _.isEmpty() Method
- How to get the function name inside a function in PHP ?
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

