Laravel Collection Public API: count

November 29, 2016 —John Koster

count

The count method is a straightforward method and simply returns the total number of items in the collection. The count method returns an integer.

1<?php
2 
3use Illuminate\Support\Collection;
4 
5// Create a new collection instance.
6$collection = new Collection([
7 'first', 'second', 'third'
8]);
9 
10// 3
11$collection->count();

Some absolutely amazing
people

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.