I have this associative array:
$products=array('chair'=>100, 'sofa'=>200, 'bed'=>300);
I need to sort this products array on basis of description i.e chair , sofa etc.
I would be writing a function compare to sort this:
compare($x, $y)
{
if $x==$y
{
.....
}
elseif $x > $y
{
......
}
else
......
here $x is teh first element of the product array i.e chair=>100 and $y is the second element
of product i.e sofa=>200... But i am trying to find out how can i access the first and second element of this associative array to pass to this compare function. With a normal numerical array i could have done ..$products[0], $products[1]...but i cannot figure this out.
Any help would be appeciated.. Thanx in advance.