PHP If Then语句基于字段输出的数字范围


PHP If Then statement based on numeric range from field output

我有一个数字字段:<?php echo $entity->field_zip_code_name[0];?>

我想根据输出数字创建一个if then语句。以下是我的文件:

if ($entity->field_areacode[0] = 92919,92923,94975,37783) {
    <h3 style="font-size: 20px;"><strong>Area Code:</strong></h3>;
}
else {
    NONE;
}

不确定x是什么,如果是$entity->field_zip_code_name[0]则回显:

if(in_array($entity->field_zip_code_name[0], [92919,92923,94975,37783])) {
    //display x
}

如果您的PHP版本不支持[],请使用array():

if(in_array($entity->field_zip_code_name[0], array(92919,92923,94975,37783))) {
    //display x
}