title: How to detect multiple strings in $_SERVER["SERVER_NAME"]?
body: <p>I would like to detect an array of strings in <code>$_SERVER["SERVER_NAME"]</code> to define a constant for environment like dev/prod.<br>
  Basically, if <code>localhost</code> or <code>.dev</code> is in the URL, that would set the constant to "prod".</p>
  
  <p>Here is my try but I always got <code>"prod"</code> even if my current url is "localhost:3000" or "site.dev":</p>
  
  <pre><code>// Define environment
  $dev_urls = array(".dev", "localhost");
  if (str_ireplace($dev_urls, "", $_SERVER["SERVER_NAME"]) == $_SERVER["SERVER_NAME"]){
      define("ENV", "dev");
  } else {
      define("ENV", "prod");
  }
  </code></pre>
  
  <hr>
  
  <p>Finally used this code which works like a charm</p>
  
  <pre><code>// Define environment
  $dev_urls = array(".dev", "localhost", "beta.");
  if (str_ireplace($dev_urls, "", $_SERVER["HTTP_HOST"]) != $_SERVER["HTTP_HOST"]){
      define("ENV", "dev");
  } else {
      define("ENV", "prod");
  }
  </code></pre>