this question has answer here:
the second condition date working fine, first condition echoing w, whether input wrong or correct. why ?
$file_name='nzl-00-2015'; list($name_loc, $name_date) = explode('-', $file_name, 2); if($name_loc != "cal" || "flp" || "arz") { echo "w";} else { echo "g";} $d = datetime::createfromformat('m-y', $name_date); if($d && $d->format('m-y') != $name_date){ echo "wrong";} else { echo "good";}
because "flp" , "arz" truthy values, if statement true. think mean:
if($name_loc != "cal" && $name_loc != "flp" && $name_loc != "arz") { or, have way - if $name_loc isn't found in array of values:
if(!in_array($name_loc, array('cal', 'flp', 'arz'))){
Comments
Post a Comment