You are here: Re: function that returns current numeric index? « PHP Programming Language « IT news, forums, messages
Re: function that returns current numeric index?

Posted by Andy Hassall on 06/10/05 01:04

On Thu, 9 Jun 2005 16:54:45 -0500, "jerrygarciuh"
<designs@no.spam.nolaflash.com> wrote:

> $ary = array('a','b','c','d');
> while ($x = array_shift($ary)) {
> echo key($ary) . ',';
> }
>
>// output is 0,0,0
>
>It seems to only work (as advertised in docs) on associative arrays.

The output is consistent, since array_shift modifies the array.

Each time you call it, it removes an entry __and shifts the numeric indices__.

For associative arrays, the keys remain the same.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

 

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

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