Php > Miscellaneous
Best deal array sorting function
Best deal array sorting function function BEST_DEALS(&$myarray) { krsort($myarray, SORT_NUMERIC); while(list($weight, $cost) = each($myarray)) { // delete bad deals, retain best deals: if(!$lastweight) { $lastweight=$weight; $lastcost = $cost; } else if($cost >= $lastcost) { unset($myarray[$weight]); } else { $lastweight=$weight; $lastcost = $cost; } } ksort($myarray); }
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage