title: change image in every three days using php
body: <p>I am creating a wordpress widget. This will allow user to upload the image url of eight different picture. Now I want to change the image everty three days and start from begining after eight one for infinite time.</p>
  
  <p>I manage to get the start of the first image. let sat that is : 2014/07/28</p>
  
  <p>I have applied this logic:</p>
  
  <pre><code>$date = $start_date;
                              $date = strtotime($date);
                              $date = strtotime("+3 day", $date);
                              $end_date = date('Y-m-d', $date);
                              $begin = new DateTime( $start_date );
                              $end = new DateTime('');
                              $end = $end-&gt;modify( '+1 day' );
                              $interval = new DateInterval('P1D');
                              $daterange = new DatePeriod($begin, $interval ,$end);
                              if($start_date &lt;= $end_date &amp;&amp; $end_date &gt; date('Y-m-d'))
                              {
                                  $image_number = 1;
                              }else{
                              $i = 1;
                              $j = 1;
                              foreach($daterange as $date){
                                  if($i%3 == 0){
                                      echo $image_number = $j;
                                      $j++;
                                      if($j &gt; 8){
                                      $j = 1;
                                      }
                                  }
                                  $i++;
                              }
                              }
  </code></pre>
  
  <p>?>
                              " alt=""></p>
  
  <p>Can anybody tell me what is wrong with the code.</p>
  
  <p>Thank you everybody in advance for your valuable time.</p>