php - Loop through 2 dates and execute a condition each 12 days, 2 days, 12 days, 2 days, etc -


i want execute condition during loop between 2 dates.

this code :

 for($i = $periodstartat; $periodstartat <= $endat; $i->modify('+1 day')){     // when it's 12 days     // when it's 2 days (after 12 days)     // when it's 12 days (after 2 days)     // etc.....     } 

anyone can algorithm ?

thanks in advance !

you can consider period 14 days long, split in 2 subperiods - first of 12 days , second of 2 days.

so each step of loop process 14 days:

$periodstartat = 0; while(true) {     $periodstartat += 12; // first sub-period     if ($periodstartat > $endat) break;     //do when first sub-period reached      $periodstartat += 2; //second sub-period      if ($periodstartat > $endat) break;     //do when second sub-period reached } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -