Reply to Re: function that returns current numeric index?

Your name:

Reply:


Posted by jerrygarciuh on 06/10/05 00:54

Andy,

Thanks for the reply. Am I using this incorrectly?

$ary = array('a','b','c','d');
while ($x = array_shift($ary)) {
echo key($ary) . ',';
}

// output is 0,0,0

$ary = array('a' => 'apple','b' => 'bear','c' => 'cat','d' => 'dog');
while ($a = array_shift($ary)) {
echo key($ary) . ',';
}

// output is b,c,d

It seems to only work (as advertised in docs) on associative arrays.

TIA for any help,

jg





"Andy Hassall" <andy@andyh.co.uk> wrote in message
news:h0bha11cj8tn5c7gg43tvska82ul7fl4p8@4ax.com...
> On Thu, 9 Jun 2005 15:47:19 -0500, "jerrygarciuh"
> <designs@no.spam.nolaflash.com> wrote:
>
>>In reading through the list of array-related functions I did not find on
>>which returns the numeric index where the array's internal pointer
>>currently
>>sits. Is there such a function?
>
> http://uk.php.net/manual/en/function.key.php
>
> --
> Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
> <http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

[Back to original 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

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