You are here: Re: How to extract from array « PHP Programming Language « IT news, forums, messages
Re: How to extract from array

Posted by harvey on 05/15/07 15:07

In article <4649c973$0$2892$6e1ede2f@read.cnntp.org>,
stereofrog@gmail.com says...
> On 15.05.2007 16:07 harvey wrote:
> > What is the easiest way to get both the last item name and last item
> > value from an associative array?
> >
> > I can get the value with array_pop() but can't see anything similar
> > for the item's name.
> >
> > Thanks
> >
>
> Try
>
> list($key, $val) = each(array_slice($a, -1));
>
> replace 'slice' with 'splice' to remove the last element.
>
>
> --
> gosha bine
>
> extended php parser ~ http://code.google.com/p/pihipi
> blok ~ http://www.tagarga.com/blok
>

That looks good too - but in the interests of clarity of code
I've gone with the previous idea.

But thanks anyway its worth playing with.

 

Navigation:

[Reply to this 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

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