April 22, 2018 —John Koster
The isEmpty
can be used to determine if the collection has items or not. If the collection has no items, true
will be returned, otherwise false
will be returned.
1public function isEmpty();
The following example demonstrates the basic usage of the isEmpty
method:
1use Illuminate\Support\Collection; 2 3// Create a new collection instance. 4$collection = new Collection; 5 6// true 7$empty = $collection->isEmpty(); 8 9// Add an item to the collection.10$collection[] = 'First item';11 12// false13$empty = $collection->isEmpty();
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.