use Doctrine\Common\Collections\ArrayCollection; //Create a new array collection with some elements $collection = new ArrayCollection(['apple', 'banana', 'cherry']); // Check if 'banana' is a key in the collection if ($collection->containsKey(1)) { echo "'banana' key exists in the collection"; } else { echo "'banana' key does not exist in the collection"; }In this example, the ArrayCollection containsKey method is used to check if the key '1' (which corresponds to the value 'banana') exists in the collection. The output will be "banana key exists in the collection". The package library used here is Doctrine\Common\Collections.