Not exactly what you asked for, but given that classes are primarily used for styling, might you consider using CSS pseudo-class “:last-child” instead of PHP code?
Here’s some information on how to style using :last-child
Not exactly what you asked for, but given that classes are primarily used for styling, might you consider using CSS pseudo-class “:last-child” instead of PHP code?
Here’s some information on how to style using :last-child