title: particular week days with repeat occurrences php
body: <p>Repeat every Tuesday of the week
      Repeat every Saturday of the week. based on the occurrences  </p>
  
  <p>example: </p>
  
  <pre><code>5 recurrence means , the event will repeat 5times like 
  tuesday , saturday, tuesday, saturday, tuesday
  </code></pre>
  
  <p>my code is</p>
  
  <p><code>$ron</code> is the user selected weekdays <code>1=monday</code>, <code>2=tuesday</code> etc.</p>
  
  <pre><code> $ron="1,5,3";
   $ronS=explode(',', $ron);
   foreach($ronS as $ronS) {
     $res[]= $ronS;
   }
   $s ="09-05-2014 00:00:00";
   $ii=0;
   $m= date("M",strtotime($s));
   $curday= 7-date("N",strtotime($s));
   foreach($res as $key=&gt;$val) 
   {
        $week = array('0'=&gt;"Sunday","1"=&gt;"Monday","2"=&gt;"Tuesday","3"=&gt;"Wednesday","4"=&gt;"Thursday","5"=&gt;"Friday","6"=&gt;"Saturday");
        $day[] = $week[$val]."-";
        $ncount= $res[$key];
        if($ii==0)
        {
            $nc=$ncount+$curday;
            $cday= date('Y-m-d H:i:s',strtotime('+'.$nc.' day',strtotime($s)));
            // echo $st=date('Y-m-d H:i:s', strtotime('Next '.$day));
            $ii++;
        } 
        else
        {
            $nc=$ncount+$curday;
            $cday= date('Y-m-d H:i:s',strtotime('+'.$nc.' day',strtotime($s)));
            $ii++;
        }
        $datetime = new DateTime("$cday");
        if ( $datetime-&gt;format("w") &gt;= 0 )
        {
           echo "\n $cday is ".$datetime-&gt;format("l")."\n";
        }
     }
  </code></pre>
  
  <p>The output of this code is:</p>
  
  <pre><code>2014-05-12 00:00:00 is Monday
  
  2014-05-16 00:00:00 is Friday
  
  2014-05-14 00:00:00 is Wednesday
  </code></pre>
  
  <p>If user input is <code>$ron="1,2,3"</code> and the occurrences is 5 ,occurrences means how many times the days will repeat.</p>
  
  <p>Example o/p:</p>
  
  <pre><code>$ron="1,3";
  $occurances=5 
  $s ="09-05-2014 00:00:00";
  </code></pre>
  
  <p>o/p will be</p>
  
  <pre><code>2014-05-12 00:00:00 is Monday
  
   2014-05-14 00:00:00 is Wednesday
  
   2014-05-19 00:00:00 is Monday
  
   2014-05-21 00:00:00 is Wednesday
  
   2014-05-26 00:00:00 is Monday
  </code></pre>