So we all know that when iterating through a PHP array using foreach, the previous index can be accessed using prev() and the next index using next(). in my case, I am iterating through a collection of objects and rendering there respective properties in my programming block.
Now I need to compare the current objects property with that of the previous object’s property. Essentially prev() would suffice if it was an array, but I am at sea trying to do the same with PHP.
Tips please!
Thanks,
Parijat
1 Answer