RE: [PHP] resetting arrays
| From: | Kim Madsen | Date: | Tue, 21 Jun 2005 13:02:25 +0000 |
| Subject: | RE: [PHP] resetting arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-217300@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: I. Gray [mailto:phpsupport@selectperformers.com]
> Sent: Tuesday, June 21, 2005 2:34 PM
> To: php-general@lists.php.net
> Subject: [PHP] resetting arrays
>
> Hi.
>
> I am sure this is easy, but I can't get this work. Is there not a php
> function that can do this?
Yes, use sort()
> I have an array- for example...
> [1] => Yellow
> [2] => Green
> [3] => Purple
> [4] => Blue
> [5] => Red
> [6] => Orange
> [7] => Cyan
This does however set yellow to 0, not 1 - run through the array with
foreach:
foreach($array AS $key => $val) {
$count++;
$new_array[$count] = $val";
}
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper