简体   繁体   中英

Combing 2 IF statements

I need to state that if a score is above 21 and the month nam is'whatever' then $month = '3'

if(strpos($data->form->name, 'april') !== false) && ($data->data->score * 1) >= 21 &&$x <= 41){
  $amonth = "3";
} 
elseif(($data->data->score * 1) >= 0 && ($data->data->score * 1) < 21){
  $month = "0";
} 

Your first line is written the wrong way, you miss some ()

Use this :

if((strpos($data->form->name, 'april') != false) && (($data->data->score * 1) >= 21 &&$x <= 41)){

Update: Sorry, I've missed a && .

It must be this to give the right result:

if((strpos($data->form->name, 'april') != false) && (($data->data->score * 1) >= 21)  && ($x <= 41)){

Only thing I can think of since your question isn't really clear.

Should be like

if(strpos($data->form->name, 'april') !== false && ($data->data->score * 1) >= 21 && $x <= 41){
  $amonth = "3";
} elseif(($data->data->score * 1) >= 0 && ($data->data->score * 1) < 21){
$month = "0";
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM