Hi, I have a query in which I need to get the last element of an array. I know we can do this via -1 as index or the array reverse function. My question is, which one is faster ? I do see on docs that array reverse creates a new array which should be more costly than iterating via negative indexes ?
Negative indexing will be faster - as you note, there is more work to do via array_reverse() and most is wasted if you only need the last item.
Thank You for the clarification !