Using get() offers two extra parameters. When $defaultValue is defined in the call, if the element is not found, $defaultValue will be returned. 默认情况下$insensitive被设置为true，使得集合中的搜索不区分大小写。 Setting this value to false will make the search for the element case sensitive.
To check whether an element exists or not in the collection, you can use the following:
The \Serializable and \JsonSerializable interfaces expose methods that allow you to serialize and unserialize the object. serialize() and unserialize() use PHP’s serialize and unserialize functions. jsonSerialize() returns an array which can be used with json_encode to serialize the object.
Phalcon\Collection also exposes two transformation methods: toArray() and toJson(int $options). toArray() returns the object transformed as an array. This method returns the same array as jsonSerialize().
toJson(int $options) returns a JSON representation of the object. It uses json_encode internally and accepts a parameter, which represents the flags that json_encode accepts. By default the options are set up with the value 74, (RFC4327) which translates to:
You can pass any valid flags to the method according to your needs.
Phalcon also offers a component that can be used in a read-only fashion. Phalcon\Collection\ReadOnly can serve as a collection in your application that can only be populated with initial data but not allowing its contents to be changed throughout the application.