Created
November 6, 2015 16:49
-
-
Save jessepearson/dd36961791d459db0697 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // go through possible packages | |
| foreach ( $possible_packages as $package ) { | |
| // add the best to a new array | |
| if ( $package->percent == $best_percent ) { | |
| $best_packages[] = $package; | |
| } | |
| } | |
| // if there's only one, that's our package | |
| if ( 1 == count( $best_packages ) ) { | |
| $best_package = $best_packages[0]; | |
| } else { | |
| // if more, go through each | |
| foreach ( $best_packages as $package ) { | |
| // get the lowest volume (smallest box) | |
| $lowest_volume = ( isset( $lowest_volume ) ) ? $lowest_volume : $package->box_vol; | |
| // and set the smallest box as the best package | |
| if ( $lowest_volume >= $package->box_vol ) { | |
| $best_package = $package; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment