| 
	
 | 
 Posted by Rik on 04/27/06 17:07 
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? 
 
It seems like the explicit keys aren't numbers, in that case this will do: 
 
$explicit = (is_numeric($key)) ? false : true; 
 
If your explicit keys can be numbers I don't think it's possible, to my 
knowledge PHP doesn''t store information about how an elemtn is added in an 
array. 
 
Grtz, 
 
--  
Rik Wasmus
 
  
Navigation:
[Reply to this message] 
 |