You are here: Re: explicit numeric keys vs item position « PHP Programming Language « IT news, forums, messages
Re: explicit numeric keys vs item position

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация