Check if ArrayCollection is empty Check if ArrayCollection is empty symfony symfony

Check if ArrayCollection is empty


Doctrine ArrayCollection has a method isEmpty that will do what you are looking for.

if ($suppliers->isEmpty()) { }

Take a look at the documentation for it here


You can also use the count() PHP function:

if (count($suppliers) < 1) { }