Jump to content

Stdclass Object.. Need To Sort By Ip And Then By Date Within Ip


newbornultra

Recommended Posts

Hi,

in essence I am outputting some information into a Excel file. But I am stuck on how to sort some an array first by IP, and then within each IP sort it by date.

 

I am pulling this information from a MySQL database, and adding it to an array of stfclass.

$newListDetails=new StdClass;
       $newListDetails->topic=$row['topic_title'];
       $newListDetails->cat=$row['cat_name'];
       $newListDetails->ip=$row['ip_remote'];
       $newListDetails->search=$row['search'];
       $newListDetails->time=$row['time'];
       $newList[]=$newListDetails;

 

And I am sorting them by IP like this:

function sortByIp($a, $B){
 return strcmp($a->ip, $b->ip);
}

usort($newList, 'sortByIp');
var_dump($newList);

 

So it's grouping the IPs like I expect it to, but now I need to sort them by date within each IP. Does anyone have any ideas how to do that?

 

Thanks,

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.