FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Using count() as an array index
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Using count() as an array index [message #178429 is a reply to message #178422] Sun, 17 June 2012 13:57 Go to previous messageGo to previous message
Martin Leese is currently offline  Martin Leese
Messages: 23
Registered: June 2012
Karma:
Junior Member
Jerry Stuckle wrote:
....
> Be aware, though - the typical array in PHP starts counting at 0, not 1.
> So an array of 3 elements would be numbered 0, 1 and 2. In this case,
> an element with an index of 3 (count($anArray)) is not set (and will
> give a warning if you try to use it).
>
> You need to get used to this idea; it's used throughout PHP.

The test code I posted was taken from my
application in which I deliberately start my
array with [1]. This is because the array
holds numbered sections of an FAQ, and it
makes more sense to have Section 1 in array
element [1], etc.

--
Regards,
Martin Leese
E-mail: please(at)see(dot)Web(dot)for(dot)e-mail(dot)INVALID
Web: http://members.tripod.com/martin_leese/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: runkit
Next Topic: PHP mysql_excape but need to search for those items
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 09:19:04 GMT 2024

Total time taken to generate the page: 0.04649 seconds