I'm trying to use this script , which returns every Monday between two periods:
$beginday = isset($_POST["Tinsem3"]) ? $_POST["Tinsem3"] : false;
$lastday = isset($_POST["Tdesl"]) ? $_POST["Tdesl"] : false;
$lastday = strtotime($lastday);
for($i = strtotime('Monday', strtotime($beginday)); $i <= $lastday; $i = strtotime('+1 week', $i))
echo date('l Y-m-d', $i);
I have adapted to get the data of the form, and the output between the dates 08/04/2015
and 08/05/2015
is already correct:
Monday, 2015-04-13
Monday, 2015-04-20
Monday, 2015-04-27
Monday, 2015-05-04
What I want is to put each of these results into variables, to be able to count how many seconds there are and to be able to use some calculations.
I have tried to do something like:
$tornararray = array (date('l Y-m-d', $i));
Then count the arrays
, with something like:
$total2 = count(array_filter($tornararray));
But when I give var_dump
of $tornararray
, I get the output:
array(1) { [0]=> string(17) "Monday 2015-05-04" }
As I understand it, it's only catching the last occurrence. How do I transform each of the results I get with echo date('l Y-m-d', $i);
into variables?
Warning: This question is not duplicate this . They are different doubts. Here I want to know how to include the results (from another script, not the one used in that question ) within variables, while in that other I have quite different goals (adapting that working day script etc ...).