Question on array sorting in php

Posted by computerwiz3491, 01-17-2008, 05:10 PM
I have the following array that I printed using print_r I need to be able to sort it by [pubDate] in highest to lowest order. How would I do this? Thanx

Posted by Codebird, 01-17-2008, 06:35 PM
you can use your pubDate as Key and then ksort($item);

Posted by computerwiz3491, 01-17-2008, 09:33 PM
It's a multi-dimensional array which has to stay in the same format.

Posted by foobic, 01-17-2008, 09:54 PM
You still need to do as Hicham suggested: create an additional array keyed on pubDate containing the same objects. Ideally you do this at the same time as creating your original array; if not you'll have to iterate through the original, eg. using array_map.

Posted by bigfan, 01-17-2008, 10:19 PM
Use array_multisort():That should work on the array as shown. (Although I think there's more to it than what you posted. If so adjust the keys for the values of $val assigned to $tmp as needed.)

Posted by bigfan, 01-18-2008, 11:39 AM
Assume an XML document like this:Then this code:will give you this: Last edited by bigfan; 01-18-2008 at 11:53 AM.

Bu mövzu kifayət qədər köməkçi oldu mu?

 Çap

Digər Başlıqlar

sdb instead of sda -> Help needed

Posted by CoolMike, 07-17-2007, 03:23 AMHi I have a server with a raid5 configuration. Linux...

Changing File ext. to File

Posted by haleyhosting_com, 03-24-2007, 01:31 PMi have a site upithere.com . its a pretty popular...

Shell Script Question

Posted by jscholes, 03-13-2010, 08:55 AMHi, I have a Windows port of the Unix/Linux uptime...

How to go about PCI compliance?

Posted by ramdak5000, 01-14-2008, 09:48 PMI have taken basic security measures on my VPS such as...

[PHP] - Why forums don't use $_SESSION variables ?

Posted by hadoken, 03-13-2007, 02:46 PMHello, I hope everybody is fine. I take a look on some...