Reply to Re: explicit numeric keys vs item position

Your name:

Reply:


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.

[Back to original 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

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