title: Check if date is allowed weekday in php?
body: <p>I'm stuck with a problem how to check if a specific date is within allowed weekdays array in php. For example,</p>
  
  <pre><code>    function dateIsAllowedWeekday($_date,$_allowed)
      {
      if ((isDate($_date)) &amp;&amp; (($_allowed!="null") &amp;&amp; ($_allowed!=null))){
      $allowed_weekdays=json_decode($_allowed);
      $weekdays=array();
  
      foreach($allowed_weekdays as $wd){
      $weekday=date("l",date("w",strtotime($wd)));
      array_push($weekdays,$weekday);
      }
      if(in_array(date("l",strtotime($_date)),$weekdays)){return TRUE;}
      else {return FALSE;}
          }
          else {return FALSE;}
      }
   /////////////////////////////   
      $date="21.05.2010"; //actually is Friday (5)
      $wd="[0,1,2]"; //Sunday,Monday,Tuesday
  
      if(dateIsAllowedWeekday($date,$wd)){echo "$date is within $wd weekday values!";} 
      else{echo "$date isn't within $wd weekday values!"}
  </code></pre>
  
  <p>I have input dates formatted as "d.m.Y" and an array returned from database with weekday numbers (formatted as 'Numeric representation of the day of the week') like [0,1,2] - (Sunday,Monday,Tuesday).</p>
  
  <p>The returned string from database can be "null", so i check it too. Then, the <code>isDate</code> function checks whether date is a date and it is ok.</p>
  
  <p>I want to check if my date, for example 21.05.2010 is an allowed weekday in this array. My function always returns TRUE and somehow weekday is always 'Thursday' and i don't know why...</p>
  
  <p>Is there any other ways to check this or what can be my error in the code above? thx</p>