|
Posted by Colin McKinnon on 04/27/06 23:20
nickdevx@hotmail.com wrote:
> Hi
>
> Say if I have a mixed array:
>
> $array = array("item1", "2"=>"item2", "5", "item4key"=>"item4")
>
> Is it possible while looping through the array (foreach ($array as
> $key=>$val)) to check if an item has an explicit key specified instead
> of its automatically assigned position key?
Confused am I. An explicit key? An automatically assigned position key? If a
key is not explicitly used in the assignment, then the next available
numeric key is used. In other words by the time you are trying to work out
what the keys are you've already passed a really bad bug in your code -
either assign all your array values with PHP working out the indices, or
specify all the keys yourself. Mixing the two together, particularly if you
want to use numeric keys, is just asking for trouble.
C.
Navigation:
[Reply to this message]
|