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