Re: resetting arrays

From: Date: Tue, 21 Jun 2005 13:05:31 +0000
Subject: Re: resetting arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-217301@lists.php.net to get a copy of this message
Thanks Richard, I had thought of sort. It almost does what I want, and really simply and neat. However it sorts the array alphabetically, and I would prefer to have things in the same order. Is there another way? Ian Gray Richard Davey wrote:
Hello, Tuesday, June 21, 2005, 1:33:55 PM, you wrote: IG> I have an array- for example... IG> What happens, say if I delete [3] => Purple? I get... IG> But what if I want to reset the numbers? Like... <?php
        $array = array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd', 4 => 'e');
        print_r($array);
                unset($array[3]);
        print_r($array);
        sort($array);
        print_r($array);
?> Best regards, Richard Davey


« previous php.general (#217301) next »