Re: Sorting an array

From: Date: Wed, 02 Jun 2004 17:31:02 +0000
Subject: Re: Sorting an array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-187466@lists.php.net to get a copy of this message
Robert Cummings wrote:
On Wed, 2004-06-02 at 12:59, John Nichel wrote:
What I would like to do is sort this on the value of 'sort' in each sub-array. What am I missing???? TIA
usort( $theAboveArray, 'mySortHandler' ); function mySortHandler( $v1, $v2 ) {
    if( $v1['sort'] > $v2['sort'] )
    {
        return 1;
    }
    else
    if( $v1['sort'] < $v2['sort'] )
    {
        return -1;
    }
    return 0;
} Cheers, Rob.
That did the trick. Thanks. -- John C. Nichel KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#187466) next »