How can I add values between two given dates? I have an array that contains date dd.mm.yyyy format and it's corresponding value.
The array:
Array
(
[0] => Array
(
[0] => 01.08.2014
[1] => 600
)
[1] => Array
(
[0] => 02.08.2014
[1] => 500
)
[2] => Array
(
[0] => 03.08.2014
[1] => 700
)
[3] => Array
(
[0] => 04.08.2014
[1] => 600
)
[4] => Array
(
[0] => 05.08.2014
[1] => 600
)
[5] => Array
(
[0] => 06.08.2014
[1] => 600
)
)
Example: 01.08.2014 to 03.08.2014 = 1800.
How can I do that using loops?
I tried this code but it didn't work.
$row_length = count($data);
$sum = 0;
for ($row = 0; $row < $row_length; $row++) {
$ax = $data[$row][1];
if ($data[$row][0] == $date1) {
$sum = $ax + $sum;
echo $test;
if ($data[$row][0] == $date2) {
break;
}
}
}