NYCPHP Meetup

NYPHP.org

[nycphp-talk] highest key of an array

Ken Robinson kenrbnsn at rbnsn.com
Mon Sep 19 17:34:12 EDT 2005


At 05:23 PM 9/19/2005, Anthony Papillion II wrote:
>  > Assuming you add keys in
>
>That triggers a question in my mind: what do you mean "sensible order"?
>When I assign a new array element doesn't PHP automatically assign the
>next highest value as it's number? Or is this something that I need to
>manage manually?

If you're just adding to an array using the '$arr[]' construct, then 
PHP will increment the index for you. But, let's say you're getting 
information out of a database and each record is uniquely identified 
by an ID number in the database. If you use that ID number as the 
index when you store the record in the array, the order you store 
them may not be in ascending  order according to that number.

Ken 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050919/a585ba72/attachment.html>


More information about the talk mailing list