Makes no sense to me what you just asked, could you clarify please? A array is a collection! <?php $myArrayCollection = array('a', 'b', 'c'); $myArrayCollection = array('a' => 'Hello', 'b' => 'World', 'c' => '!'); ?> Code (markup):
There are no collections in PHP. They are Java langauge structure. PHP uses variables (array, int, string, bool) and objects (classes).
I've never heard of a collection in PHP, you're probably thinking of an array. An array is a type of variable in PHP.
I hadn't heard of a collection in PHP neither until I started reading the cookbook of Symfony 2 which is based on PHP. Here are a few lines from it: Now what do they mean by defaults collection? How is defaults a collection here? Am I supposed to know this stuff from PHP? Here is some more:
Sounds to me like there is not real difference. The ArrayCollection object is an array, and when used inside whatever class it gives you more operational functionality like an object. In php, i can define an object out of a class , but it can be an array form, its just being from a class, its kinda officially an object.
As I said above: Basically, the $products property (which is just a regular variable, but found inside a class, which is why we call it a property) is an object (an instance of the ArrayCollection class in this case). I am guessing it is a helper class included in Symfony2 by default. However, it has nothing to do with the core PHP and its language constructs, variable types or syntax. It is just a custom class provided by Symfony which you can use to create objects (instances of that class). I am guessing you took your quote from here? If so, I don't know if you have noticed, but each code block on that page has tabs above it for different language syntaxes. The one you copied is for YAML, not PHP. Here's the one for PHP, which should make much more senses: use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; $collection = new RouteCollection(); $collection->add('blog', new Route('/blog/{page}', array( '_controller' => 'AcmeBlogBundle:Blog:index', 'page' => 1, ))); return $collection; PHP: Wherever you see the word "new" before a funny looking word, it means we are creating a new object/instance of the class that has the funny looking word. You should look more into the OOP aspect of PHP to gain deeper understanding of the concept. Also, if you think I've helped you a bit, don't forget to select my answer as the solution to this thread.