Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function buildDriveInventory($inventory) {
  2. $type = [1, 2, 4, 6, 8, 10, 12, 14, 16];
  3. $unit = "lbs";
  4.  
  5. //create new array to hold values
  6. $new_values = [];
  7.  
  8. foreach ($type as $type_value) {
  9. foreach ($inventory as $product) {
  10. if ($type_value === $product['capacity']) {
  11. $new_values[$product['capacity'].$product['unit']] = $product['total'];
  12. } else {
  13. $new_values[$type_value.$unit] = 0;
  14. }
  15. }
  16. }
  17.  
  18. return $new_values;
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement