I've read all the documentation for these and some stackoverflow posts but I still can't understand the use of this unless it's the oop approach because everything else seems the same. Where should I ditch the normal array use and use ArrayObject and/or ArrayIterator? Thanks

    If you have an object that represents some sort of indexable collection you can implement ArrayAccess so that you can have all the functionality of your object relevant to the collection, and also access it as an array. That requires you to write all the array access functionality though, so if you don't want to do all that you can extend ArrayObject instead. ArrayIterator is to allow multiple concurrent iterations over an ArrayObject by having an object to manage iteration state for each one.

    That said, I haven't had much use for them as they don't support HOFs like array_map.

    Weedpacket ArrayIterator is to allow multiple concurrent iterations over an ArrayObject by having an object to manage iteration state for each one.

    I've found ArrayIterator to be useful when you need to iterate over a dynamically generated array. So if you need to loop through and array that will keep growing, this is how you do it. Unfortunately, it's also a really good way to exhaust memory and choke your app.

      [Mod: Spam reply removed; repost of reddit thread closed.]

        Write a Reply...