Hi,
how can I sort an associative array based on the key?
I have a session variable to hold a cart and want to sort them based on item id.
$SESSION['cart'][123] = 3
$SESSION['cart'][34] = 1
$SESSION['cart'][456] = 2
$SESSION['cart'][12] = 4
when I am outputing the cart I want it to be sorted as:
$SESSION['cart'][12]
$SESSION['cart'][34]
$SESSION['cart'][123]
$SESSION['cart'][456]
so whe I do a foreach ($_SESSION['cart'] as $itemid=>qty) I get it lisetd as a sorted array.
Thanx.