Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8905335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:22:13+00:00 2026-06-15T02:22:13+00:00

how do i achieve the above result with for / foreach loop [Picture 2]?

  • 0

enter image description here

how do i achieve the above result with for / foreach loop [Picture 2]? ive googled around but could not find the answer what i want…

$name = array('D1','D2','D3' );

foreach ( $name as $k=> $v ) {
  $openTime3 = strtotime('10:00');
  $closeTime3 =  strtotime('15:00');

  echo '<div class="col"> <span class="header">'.$v.'</span>';

  while ( $openTime3 < $closeTime3 ) {
     if ( ( date('Hi', $openTime3) > '1030'  && date('Hi', $openTime3) < '1130' ) && $k == 1) {
        echo '<span class="body "><a href="#" class="unconfirmed">B</a></span>';
        break; /* ???? */
        // try to use continue or break, and it didnt work i above result.
     } else {
        echo '<span class="body"><a href="#" class="available">AV</a></span>';
     }

     $openTime3 = strtotime('+15 minutes', $openTime3);
  }

  echo '</div>';
}

css code:

.col { text-align: center; width: auto; float: left; }
.col > span { display: block; }
.col > span > a {height: 26px;line-height: 26px;display: block; padding: 0 10px; }
.col > span > .available { background: #D6F2F4; }

above code always return below result [Picture 1]:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:22:14+00:00Added an answer on June 15, 2026 at 2:22 am

    I added unconfirmed style to your css with border color same as background. Use flag to toggle B

    <style>
    .col { text-align: center; width: auto; float: left; }
    .col > span { display: block; }
    .col > span > a {height: 26px;line-height: 26px;display: block; padding: 0 10px; }
    .col > span > .available { background: #D6F2F4;border-style:solid;
    border-width:1px;}
    .col > span > .unconfirmed { background: #ffff99;border-style:solid;
    border-width:1px;border-color: #ffff99;}
    
    </style>
    <?php
    $name = array('D1','D2','D3' );
    $flag=0;//Set flag off
    foreach ( $name as $k=> $v ) {
      $openTime3 = strtotime('10:00');
      $closeTime3 =  strtotime('15:00');
    
      echo '<div class="col"> <span class="header">'.$v.'</span>';
    
      while ( $openTime3 < $closeTime3 ) {
    
         if ( ( date('Hi', $openTime3) > '1030'  && date('Hi', $openTime3) < '1130' ) && $k == 1) {
    
            if($flag==0){
            echo '<span class="body "><a href="#" class="unconfirmed"></a></span>';//Hide B
            $flag=1;Toggle flag on
            }else{
            echo '<span class="body "><a href="#" class="unconfirmed">B</a></span>';Show B
            $flag=0;Toggle flag off
            }
    
         } else {
            echo '<span class="body"><a href="#" class="available">AV</a></span>';
         }
         //$flag=1;
         $openTime3 = strtotime('+15 minutes', $openTime3);
      }
      echo '</div>';
    }
    ?>
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to achieve was is shown on the picture above. I have a
Is the above question possible? The effect I'm trying to achieve is similar to
I want to achieve the effect that is used on this Header on this
What I want to achieve : Take a keyword array as input and query
What I want to achieve is to load a text file and then count
I have a seemingly very small problem, but I can't find a solution for
Here is a basic scenario (I'm not doing this to align text specifically, but
I want the jquery date picker to appear above, i.e, partly within and outside
What I am trying to achieve is to be able to print the result
what i am trying to achive is as follows: in the image above you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.