I am creating a for loop where i want condition to be like this:
if(get_field('top', $post->ID) == "Yes")
{
$HeadClass = "first";
$priority = 1;
}
else
{
$priority = 2;
$HeadClass = "second";
}
switch($HeadClass)
{
case "first":
$ImgHolderStyle = 'style="position:relative;height:300px;background:#212121;"';
$ImgStyle = 'style="position:absolute;left:192px;" src="images/img1.jpg" width="300" height="300"';
$TitleBox = 'title-box';
$TitleBg = 'bg';
$NamedClass= '';
$TitleNewsClass= '';
$PostTitleClass = '';
$View = true;
$ExtraClass = "888";
break;
case "second":
$ImgHolderStyle = 'style="width:235px;height:276px;"';
$ImgStyle = 'width="240" height="276"';
$TitleBox = '';
$TitleBg = '';
$View = false;
$ExtraClass = "";
break;
}
in above code i want IF
condition to be run till its true, then it go to else. I mean according to the occurance of $HeadClass = "first";
run only if, when this get false then goto to ELSE
.
What output i am getting id:
<div class="first"></div> <div class="second"></div> <div class="second"></div> <div class="first"></div>
What i want to be is:
<div class="first"></div> <div class="first"></div> <div class="second"></div> <div class="second"></div>
$priority = 1;
while( .... ) {
if ( 1===$priority && 'Yes'!=get_field('top', $post->ID) ) {
$priority = 2;
}
switch($priority) {
case 1:
$HeadClass = 'first';
$ImgHolderStyle = 'style="position:relative;height:300px;background:#212121;"';
// ...
break;
case 2:
$HeadClass = "second";
$ImgHolderStyle = 'style="width:235px;height:276px;"';
// ...
break;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.