Save memory by switching to generators
Though the generators look cool, I've never used them much because I didn't find a good use case. Evert Pot demonstrates on his blog how they can help conserve memory.
Since the release of PHP 5.5, we now have access to generators. Generators are a pretty cool language feature, and can allow you to save quite a bit of memory if they are used in the right places.http://evertpot.com/switching-to-generators/