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.

Ця відповідь Вам допомогла?

 Роздрукувати цю статтю

Також прочитайте

DNS & MX RECORDS ON A CPANEL WHM VPS SERVER

Posted by Harry E, 01-13-2008, 10:37 AMHello i have been having probelems for the past few...

Need Shell script to add prefix to multiple files' name.

Posted by viettechorg, 03-25-2007, 02:09 PMHello, Does anyone know any of the shell script(or...

JaguarPC reselling program?

Posted by Snoopy, 09-28-2001, 11:22 PMHi, I am looking for a good reseller program....

DirectAdmin email forwarding not forwarding

Posted by river1, 06-30-2008, 07:20 AMI had email forwarding from a site that I am running on a...

apf and iptables

Posted by smrtalex, 01-11-2008, 02:12 AMDoes the iptables service need to be running in order for...