NYCPHP Meetup

NYPHP.org

[nycphp-talk] Overriding Array's

Jon Baer jonbaer at jonbaer.com
Wed May 2 17:39:04 EDT 2007


Are you sure you need to even do the loop?

Why not always array_unshift() the $links array ...

array_unshift() prepends passed elements to the front of the array.  
Note that the list of elements is prepended as a whole, so that the  
prepended elements stay in the same order. All numerical array keys  
will be modified to start counting from zero while literal keys won't  
be touched.

You get FIFO w/ the # index w/o doing the work.

- Jon

On May 2, 2007, at 3:04 PM, Joseph Crawford wrote:

> ok let me try to clarify myself.
>
> I somehow need to loop over all elements and see if any of them
> contain numeric indexes like the stylesheets does.  If it does we need
> to add the new element from the secondary array to the first.
>
> If it get's to the bottom element (without finding a numeric key
> first) it will replace the value such as in $data['page']['title']
>
> Is that clear?
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list