WordPress.org

Ready to get started?Download WordPress

Forums

condense PHP if statement (2 posts)

  1. bremmerm
    Member
    Posted 3 years ago #

    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")

  2. Rahul Sonar
    Member
    Posted 3 years ago #

    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..
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.