Jump to content

Sorting


unidox

Recommended Posts

Take a look at the usort function here:

 

http://www.php.net/manual/en/function.usort.php

 

You could define a function

 

function compare ($array1, $array2) {

  if (array1['discount'] < array2['discount']) {

    return -1;

  } else if (array1['discount'] > array2['discount']) {

    return 1;

  } else {

    return 0;

  }

}

 

then pass the name of this function as the 2nd argument to usort

Link to comment
https://forums.phpfreaks.com/topic/209701-sorting/#findComment-1094735
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.