Re: Re-sorting array indices numerically.
| From: | Danny Shepherd | Date: | Mon, 17 Jun 2002 16:18:49 +0000 |
| Subject: | Re: Re-sorting array indices numerically. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102537@lists.php.net to get a copy of this message | ||
Or you could use
$tmpArray=Array();
foreach($origArray as $value)
$tmpArray[]=$value;
$origArray=$tmpArray;
But it may be bit inefficient - and slow when used on huge arrays.
Danny.
----- Original Message -----
From: "Danny Shepherd" <danny@kyboshed.com>
To: "Martin Clifford" <MLC1@nrc.gov>; <php-general@lists.php.net>
Sent: Monday, June 17, 2002 5:15 PM
Subject: Re: [PHP] Re-sorting array indices numerically.
> If you arn't bothered about the order of the items you could just use
> sort($array).
>
> Id imagine there's a better way though.
>
> Danny.
>
> ----- Original Message -----
> From: "Martin Clifford" <MLC1@nrc.gov>
> To: <php-general@lists.php.net>
> Sent: Monday, June 17, 2002 4:35 PM
> 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
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>