An array to add and calculate an include file.
Posted: Sat Feb 11, 2012 9:52 am
I'm trying to learn about arrays and how they work. The problem is that I have an include file in the following format that I need to add the total days that each piece of equipment is rented for and display it in a report.
<?php
$rentals =
"Equipment01 1 3 13
Equipment99 11 17 22"
?>
Each row contains a set of 4 values. The equipment serial#, the number equivalent of the month, the day of the month and the quantity of days the equipment was rented. Currently I have a long if/elseif statement and count/accumulator variables to do the task and it works fine. However, I'm trying to learn more efficient ways of coding and from what I've been reading, I think an array is the best option.
This is just part of the task as the include file does not contain the daily rental rate for each piece of equipment. If I understand it well enough, my thought is that one array would be generated from the include file and another array would be hard coded with the daily rates. After these steps, a report would need to be generated to show each piece of equipment and totals for how many days each were rental and the total amount of revenue. Sorting the data by equipment with the most revenue would be a cool feature.
This is a class assignment that I already completed and it works as it needs to, but I'm trying to take it further and learn more.
For additional info on the process, you can find details at...
viewtopic.php?f=50&t=134320&p=670987#p670987
I might be biting off more than I can handle, but learning is a process.
<?php
$rentals =
"Equipment01 1 3 13
Equipment99 11 17 22"
?>
Each row contains a set of 4 values. The equipment serial#, the number equivalent of the month, the day of the month and the quantity of days the equipment was rented. Currently I have a long if/elseif statement and count/accumulator variables to do the task and it works fine. However, I'm trying to learn more efficient ways of coding and from what I've been reading, I think an array is the best option.
This is just part of the task as the include file does not contain the daily rental rate for each piece of equipment. If I understand it well enough, my thought is that one array would be generated from the include file and another array would be hard coded with the daily rates. After these steps, a report would need to be generated to show each piece of equipment and totals for how many days each were rental and the total amount of revenue. Sorting the data by equipment with the most revenue would be a cool feature.
This is a class assignment that I already completed and it works as it needs to, but I'm trying to take it further and learn more.
For additional info on the process, you can find details at...
viewtopic.php?f=50&t=134320&p=670987#p670987
I might be biting off more than I can handle, but learning is a process.