Arrays: new and old keys, i

Trevor DeVore lists at mangomultimedia.com
Thu Sep 11 17:20:36 EDT 2008


On Sep 11, 2008, at 4:59 PM, Mark Wieder wrote:

> I don't think this is properly the function of an array. If you're
> talking about adding engine support for LIFO or FIFO stacks or queues
> then that's a slightly different topic. But trying to access array
> elements in the order they were added is a bit like trying to do the
> same with database records - it's just not, strictly speaking, the way
> databases work.

Hey Mark,

I'm thinking of how PHP behaves. Arrays in PHP know the order that  
elements were added so that when you use foreach you get the elements  
in that same order. I always found this very useful when working with  
arrays in PHP.

For a little more info on what PHP does take a look at the comment by  
php_man_resp on the foreach page in the docs:

<http://www.php.net/foreach>

> If you're using numeric arrays and you add elements in sequential
> order, then note that you can get what you want by saying
>
> put theArrayA[5]

This is what I currently do and it works fine in many cases. But some  
things could be simplified if foreach iterated in the order keys were  
added.

Regards,

-- 
Trevor DeVore
Blue Mango Learning Systems
www.bluemangolearning.com    -    www.screensteps.com



More information about the use-livecode mailing list