Re: a quick question about array keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 31 August 2010 16:45, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> There are two ways I see to do it. You can iterate the array and create
> a copy, assigning elements dynamic values:
>
> $new_array = array();
> foreach($array as $a)
> {
>    $new_array[] = $a;
> }
>
> or use a sorting function on it that doesn't preserve the keys (as in
> your example all the values in the array were in numerical order.
>
> $new_array = sort($array);

sort() operates in the array. It does not return a new array, just a
bool to indicate success or not.

http://docs.php.net/sort



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux