PHP | Ds\Collection isEmpty() Function
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
$collection = new \Ds\Vector([10, 15, 21, 13, 16, 18]);
$res = $collection ->isEmpty();
var_dump( $res );
$collection = new \Ds\Vector();
$res = $collection ->isEmpty();
var_dump( $res );
?>
|
Output:
bool(false)
bool(true)
Example 2:
<?php
$collection = new \Ds\Vector();
var_dump( $collection ->isEmpty());
$collection = new \Ds\Vector([1, 3, 5, 2, 6]);
var_dump( $collection ->isEmpty());
?>
|
Output:
bool(true)
bool(false)
Reference: http://php.net/manual/en/ds-collection.isempty.php
Last Updated :
21 Jan, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...