Menu
hi guys, try as i may i can’t seem to wrap my head around array keys.
i have an array of categories listed on no particular order.
i use asort() to get them into alphabetical order, and now
i need to loop through the array and print each one as a clickable
link with the corresponding key.
i tried using key(), with a regular ‘for loop’ but the same key is being
printed for every element of the array.
here’s my code…
asort($data); //name of array is $data
for( $i = 0; $i < sizeof($data); $i++ ){
echo “<li>$data[$i] ” . key($data);
}
how can i correct it to get the proper key?
thanks,
Michael.