Re: Re-sorting array indices numerically.
| From: | Kevin Stone | Date: | Mon, 17 Jun 2002 16:33:17 +0000 |
| Subject: | Re: Re-sorting array indices numerically. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102543@lists.php.net to get a copy of this message | ||
The array_values() function was designed to extract values from associative
array and put them into an indexed list.. but it serendipitously it also
does the job of reindexing a broken list.
http://www.php.net/manual/en/function.array-values.php
$array = array_values($array);
-Kevin
----- Original Message -----
From: "Martin Clifford" <MLC1@nrc.gov>
To: <php-general@lists.php.net>
Sent: Monday, June 17, 2002 9:35 AM
Subject: [PHP] Re-sorting array indices numerically.
> Howdy all,
>
> I have finally been able to remove single elements from an array with the
unset() function, and that works great. But now, if there are these items
in the array:
>
> [0] Fruit
> [1] Eggs
> [2] Bacon
>
> After the unset() function does it's mojo to remove Eggs, the array is
thus:
>
> [0] Fruit
> [2] Bacon
>
> My question is this: How do I resort the array so that after the unset()
function goes through, the array would be this, having deleted Eggs:
>
> [0] Fruit
> [1] Bacon
>
> Thanks in advance! Please reply directly, as I'm on the digest.
>
> Martin
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>