Jump to content

Sorting a multidimensional Array


andrewjackson

Recommended Posts

Hey guys,

 

I've been racking my brain all day over this one, and I'm sure it's something simple that I'm missing.

 

 

I need to sort an array by a specific key. Below is a snippet of my array

 


SimpleXMLElement Object
(
    [CarListing] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [id] => 143982
                    [DataType] => CarAdvert
                    [ExternalReference] => ST2365939
                    [Title] => SUBARU IMPREZA WRX 1996
                    [shortDescription] => 46mm Trust wastegate, HKS SSQ Bov, Greddy T/timer, Apexi Pod filter & cold air box, Huge Front mount, Full 3” Stainless exhaust system, Adjustable Suspension, Boost Gauge, Black taillights, 18” mags,
                    [Make] => SUBARU
                    [Model] => IMPREZA
                    [Price] => 11000.0000
                    [PriceDescription] => ono
                    [Year] => 1996
                    [series] => WRX
                    [ListingType] => Used
                    [PrimaryImageURL] => HTTP://203.36.33.170/WebFiles/IMT/1/34/014290184.jpg
                    [DateCreated] => 2008-05-07T08:56:15.407
                    [LastModified] => 2008-05-07T08:56:15.407
                    [sellerName] => Arne Stewart
                    [sourceSystem] => ST
                    [sellerType] => Private
                    [PageViews] => 1459
                    [isPremiumAd] => false
                    [FuelType] => Not Supplied
                    [EngineCapacity] => SimpleXMLElement Object
                        (
                        )

                    [bodyType] => Sedan
                    [Odometer] => SimpleXMLElement Object
                        (
                        )

                    [Doors] => Not Supplied
                    [Location] => New Zealand
                    [HasVideo] => SimpleXMLElement Object
                        (
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [id] => 264600
                    [DataType] => CarAdvert
                    [ExternalReference] => DP1210486
                    [Title] => SUBARU LEGACY 2002
                    [shortDescription] => Stock #: 8267 Type: Station Wagon Ext Colour: Silver Metallic Transmission: 4 Speed Auto CC Rating: 2000 cc Odometer: 89,900 kms Features: 4WD, 5 Door, ABS Brakes, Air Bag(s), Air Conditioning, Alarm
                    [Make] => SUBARU
                    [Model] => LEGACY
                    [Price] => 12995.0000
                    [PriceDescription] => SimpleXMLElement Object
                        (
                        )

                    [Year] => 2002
                    [series] => SimpleXMLElement Object
                        (
                        )

                    [ListingType] => Used
                    [iFinanceDealersStock] => IFinance
                    [MtaDealersStock] => MTA
                    [MtaNumber] => 67776
                    [PrimaryImageURL] => http://www.dealerpoint.co.nz/ImageServer/DisplayImage.aspx?Image_ID=2370125&ItemType=Car&Width=70
                    [DateCreated] => 2008-07-22T09:58:24.363
                    [LastModified] => 2008-07-22T09:58:24.363
                    [sellerName] => Macdonald Halligan Motors Limited
                    [sellerLogoUrl] => http://www.dealerpoint.co.nz/ImageServer/DisplayImage.aspx?Image_ID=1355&ItemType=DEALERLOGO&Width=70
                    [sellerLogoHref] => SimpleXMLElement Object
                        (
                        )

                    [sourceSystem] => DP
                    [DealerExternalReference] => 3287
                    [DealerId] => DP3287
                    [sellerType] => Dealer
                    [PageViews] => 346
                    [isPremiumAd] => false
                    [FuelType] => Petrol
                    [EngineCapacity] => 2000
                    [bodyType] => Station wagon
                    [Odometer] => 89900
                    [Doors] => 5 Door
                    [Transmission] => 4spd auto
                    [Colour] => Silver Metallic
                    [Location] => Auckland
                    [HasVideo] => SimpleXMLElement Object
                        (
                        )

                    [stockNumber] => 8267
                )

            [2] => SimpleXMLElement Object
                (
                    [id] => 280787
                    [DataType] => CarAdvert
                    [ExternalReference] => DP1223048
                    [Title] => SUBARU IMPREZA 2001
                    [shortDescription] => Airbag - Dual, Central Locking, Power Steering, ABS Brakes, Alloy Wheels, Electric Mirrors, Air Conditioning, Airbags, CD Player, Electric Windows 
                    [Make] => SUBARU
                    [Model] => IMPREZA
                    [Price] => 9995.0000
                    [PriceDescription] => SimpleXMLElement Object
                        (
                        )

                    [Year] => 2001
                    [series] => SimpleXMLElement Object
                        (
                        )

                    [ListingType] => Used
                    [MtaDealersStock] => MTA
                    [MtaNumber] => 402613
                    [PrimaryImageURL] => http://www.dealerpoint.co.nz/ImageServer/DisplayImage.aspx?Image_ID=2429948&ItemType=Car&Width=70
                    [DateCreated] => 2008-08-25T11:00:09.053
                    [LastModified] => 2009-10-29T15:47:22.253
                    [sellerName] => Watts Motors Ltd
                    [sellerLogoUrl] => SimpleXMLElement Object
                        (
                        )

                    [sourceSystem] => DP
                    [DealerExternalReference] => 4500
                    [DealerId] => DP4500
                    [sellerType] => Dealer
                    [PageViews] => 314
                    [isPremiumAd] => false
                    [FuelType] => Petrol
                    [EngineCapacity] => 1500
                    [bodyType] => Hatchback
                    [Odometer] => 75000
                    [Doors] => 5 Door
                    [Transmission] => Auto
                    [Colour] => RED
                    [Location] => Hawkes Bay Poverty Bay
                    [HasVideo] => SimpleXMLElement Object
                        (
                        )

                    [stockNumber] => 4961
                )

            [3] => SimpleXMLElement Object
                (
                    [id] => 79769
                    [DataType] => CarAdvert
                    [ExternalReference] => DP1124382
                    [Title] => SUBARU SAMBER 1993
                    [shortDescription] => SUBARU, 4WD, Central Locking, Power Steering, Radio / Cassette, Air Conditioning 
                    [Make] => SUBARU
                    [Model] => SAMBER
                    [Price] => 8995.0000
                    [PriceDescription] => SimpleXMLElement Object
                        (
                        )

                    [Year] => 1993
                    [series] => SimpleXMLElement Object
                        (
                        )

                    [ListingType] => Used
                    [iFinanceDealersStock] => IFinance
                    [MtaNumber] => SimpleXMLElement Object
                        (
                        )

                    [PrimaryImageURL] => http://www.dealerpoint.co.nz/ImageServer/DisplayImage.aspx?Image_ID=2005110&ItemType=Car&Width=70
                    [DateCreated] => 2007-11-22T10:46:43.92
                    [LastModified] => 2009-10-23T11:27:45.913
                    [sellerName] => Mosgiel Motor Court
                    [sellerLogoUrl] => http://www.dealerpoint.co.nz/ImageServer/DisplayImage.aspx?Image_ID=205&ItemType=DEALERLOGO&Width=70
                    [sourceSystem] => DP
                    [DealerExternalReference] => 2951
                    [DealerId] => DP2951
                    [sellerType] => Dealer
                    [PageViews] => 543
                    [isPremiumAd] => false
                    [FuelType] => Petrol
                    [EngineCapacity] => 660
                    [bodyType] => Ute
                    [Odometer] => 62000
                    [Doors] => 2 Door
                    [Transmission] => 5spd manual
                    [Colour] => White
                    [Location] => Otago
                    [HasVideo] => SimpleXMLElement Object
                        (
                        )

                    [stockNumber] => 1429
                )
       )
)

 

I need to be able to sort this array by Date, Price, etc...

 

Any help would be greatly appreciated

 

cheers,

Andrew

Link to comment
https://forums.phpfreaks.com/topic/179568-sorting-a-multidimensional-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.