Reply to Re: [PHP] Simple array question, part 2

Your name:

Reply:


Posted by Brent Baisley on 04/06/05 20:12

Just so you know what is happening, the numbers are keys (index) for
each array element, not the order number. It's the same as if you had
named the elements themselves. Like this:
['zero']=>158
['one']=>169926
['two']=>169931
....

Or
[0]=>158
[12]=>169926
[5]=>169931
....

Deleting an element won't reorder the names of the elements since php
wouldn't know how.


On Apr 6, 2005, at 12:37 PM, Ryan A wrote:

> Hey,
> I have a $data array like this:
> [0] => 158
> [1] => 169926
> [2] => 169931
> [3] => 169932
> [4] => 169933
> then when i delete the first one ([0] => 158) it becomes like this:
> [1] => 169926
> [2] => 169931
> [3] => 169932
> [4] => 169933
>
> how do I get it to sort again from 0,1,2,3 etc?
>
> I tried sort(), ksort(),reset() etc....but it still shows as starting
> from 1
> instead of resorting the keys starting from 0
>
> what function should i lookup/use?
>
> Thanks,
> Ryan
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.3 - Release Date: 4/5/2005
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

[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

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