title: PHP - Loop while 'false', stop when it is 'true'
body: <p>I want to get tomorrow date. But if tomorrow is <code>Saturday</code> or <code>Sunday</code>. It will get date in <code>Monday</code>. It will skip Saturday and Sunday. Also if tomorrow is holiday, it will skip the date and get the next date. I have list of holiday date in my database.</p>
  
  <p>I've trying this code. Suppose today is <code>Friday, May 24</code>.</p>
  
  <pre><code>$today = "2013-05-24";
  
  $tommorow = date('Y-m-d', strtotime($today . ' + 1 day'));
  $valid = check_valid($tommorow);
  while (!$valid){
      $tommorow = date('Y-m-d', strtotime($today . ' + 1 day'));
      $valid = check_valid($tommorow);
      if($valid){
          break;
      }
  }
  
  function check_valid($date){
      return true;
      $timestamp = strtotime($date);
      $day = date('D', $timestamp);
      if ($day == "Sat" || $day == "Sun"){
          return false;
      }
      $mysql= mysql_query("SELECT * FROM holiday_data WHERE date = '$date'");
      if (mysql_num_rows($mysql) &gt;= 1){
          return false;
      }
  }
  </code></pre>
  
  <p>I'm using <code>while</code> clause because i assume that there is <code>holiday date</code> that appears in two or three days in a row. For example, holiday is on May 27 and 28, then tomorrow date should be in <code>Wednesday</code>.</p>
  
  <p>Any ideas?
  Could you help me please?</p>
  
  <p>If you have another approach to achieve this, I also want to know it.</p>
  
  <p>Thank you,</p>