Questions tagged «arraycollection»

8
如何合并两个PHP Doctrine 2 ArrayCollection()
有什么方便的方法可以让我串联两个教义ArrayCollection()吗?就像是: $collection1 = new ArrayCollection(); $collection2 = new ArrayCollection(); $collection1->add($obj1); $collection1->add($obj2); $collection1->add($obj3); $collection2->add($obj4); $collection2->add($obj5); $collection2->add($obj6); $collection1->concat($collection2); // $collection1 now contains {$obj1, $obj2, $obj3, $obj4, $obj5, $obj6 } I just want to know if I can save me iterating over the 2nd collection and adding each element one by one to …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.