Re: a quick question about array keys

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

 



On 31 August 2010 17:49, Richard Quadling <rquadling@xxxxxxxxx> wrote:
> On 31 August 2010 17:39, Richard Quadling <rquadling@xxxxxxxxx> wrote:
>> On 31 August 2010 17:06, Tontonq Tontonq <rootdot@xxxxxxxxx> wrote:
>>> Array
>>> (
>>> [300] => 300
>>> [301] => 301
>>> ...

If you add a ...

sort($data) ...

just before the foreach() loop...

Array
(
    [0] => 101
    [1] => 165-173
    [2] => 201-215
    [3] => 300-316
    [4] => 987
)

Watch out for duplicate values.

I changed 315 and 316 to 305 and 306...

unsorted ...

Array
(
    [0] => 300-314
    [1] => 165-173
    [2] => 201-215
    [3] => 101
    [4] => 305-306
    [5] => 987
)

sorted ...

Array
(
    [0] => 101
    [1] => 165-173
    [2] => 201-215
    [3] => 300-305
    [4] => 305-306
    [5] => 306-314
    [6] => 987
)

-- 
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