mtd
07-12-2005, 03:12 AM
Hello. I need to find the position (or, index value) of various keys in an array. They are numerical, but because of an earlier asort(), they are no longer in numerical order.
In simplified form, I have:
$arrayName = array('Book','Apple','Zebra','Lake');
)
asort($arrayName)
foreach($arrayName as $key=>$value) {
echo $value.'<br>';
}
FYI - I needed to use foreach() instead of a for($i=0 ...) loop because that would mess up the order created by the asort().
Now, I must find the position of the $key in the array. Like I said, because of the asort(), a $key with the value of 0 won't necessarily be in the 0th position, etc. Is there any built in function to do this? If not, how can I find it myself?
Thanks!
In simplified form, I have:
$arrayName = array('Book','Apple','Zebra','Lake');
)
asort($arrayName)
foreach($arrayName as $key=>$value) {
echo $value.'<br>';
}
FYI - I needed to use foreach() instead of a for($i=0 ...) loop because that would mess up the order created by the asort().
Now, I must find the position of the $key in the array. Like I said, because of the asort(), a $key with the value of 0 won't necessarily be in the 0th position, etc. Is there any built in function to do this? If not, how can I find it myself?
Thanks!