Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function buildDriveInventory($inventory) {
- $type = [1, 2, 4, 6, 8, 10, 12, 14, 16];
- $unit = "lbs";
- //create new array to hold values
- $new_values = [];
- foreach ($type as $type_value) {
- foreach ($inventory as $product) {
- if ($type_value === $product['capacity']) {
- $new_values[$product['capacity'].$product['unit']] = $product['total'];
- } else {
- $new_values[$type_value.$unit] = 0;
- }
- }
- }
- return $new_values;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement