WordPress.org

Support

Support » How-To and Troubleshooting » condense PHP if statement

condense PHP if statement

  • Is there a way to make this shorter?:

    if($shipping_country == "BG" || $shipping_country == "EE" || $shipping_country == "FI" || $shipping_country == "HU" || $shipping_country == "IE" || $shipping_country == "LV" || $shipping_country == "LT" || $shipping_country == "PL" || $shipping_country == "PT" || $shipping_country == "RO" || $shipping_country == "SI" || $shipping_country == "SK" || $shipping_country == "CZ")

Viewing 1 replies (of 1 total)
  • This is not a question related to wordpress..

    still, answer to your question:

    $ar = array("BG", "EE", "FI", .....);
    if(in_array($shipping_country, $ar)) {
    // do something..
    }
Viewing 1 replies (of 1 total)
  • The topic ‘condense PHP if statement’ is closed to new replies.