Dimas Adi Andrea Dimas Adi Andrea -4 years ago 109
PHP Question

Displaying cart codeigniter from newest added first

This is my code:

$cart = $this->cart->contents();
foreach ($cart as $item){

}


How to display cart from newest added first?
Thanks.

Answer Source

Use array_reverse function

$reversed_cart = array_reverse($cart);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download