PHP IF Statement how can I write it more elegant and effective
<p>I now have this code based on some of the answers below.</p>

<p>Is this the most elegant, clean, fast and effective code to have?</p>

<pre><code>&lt;?php
/**
 * The default template for displaying Google Analytics
 *
 * @package WordPress
 * @subpackage News_Template
 * @since News Template 1.0
 */
$googleanalyticscode="&lt;script type='text/javascript'&gt; var _gaq = _gaq || []; _gaq.push(['_setAccount', '%s']); _gaq.push(['_setDomainName', '%s']);   _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); &lt;/script&gt;";
$analyticsurlgoogle=array(
    'domain-a.com' =&gt; 'UA-25133-2',
    'domain-b.com' =&gt; 'UA-25133',
    'domain-c.com' =&gt; 'UA-2699-2',
    'domain-d.com' =&gt; 'UA-3021-2',
    'domain-e.com' =&gt; 'UA-25537-2',
    'domain-f.com' =&gt; 'UA-7213-2',
    'domain-g.com' =&gt; 'UA-7214-2',
    'domain-h.com' =&gt; 'UA-150-2',
    'domain-i.com' =&gt; 'UA-150-2'
); 
// --- /Configuration --- 
// Get the Domain URL 
$analyticsurl = get_site_url(); 
$namegoogle = substr($analyticsurl,7); 
//create code 
if (isset($analyticsurlgoogle[$namegoogle])) $code=sprintf($googleanalyticscode,$analyticsurlgoogle[$namegoogle],$namegoogle); 
else $code=''; 
echo $code; ?&gt;
</code></pre>

<p>------ Previous Code ------</p>

<p>I have written the following if statement in PHP. What would be the most elegant, effective and cleanest way of writing this code?</p>

<p>The purpose of the code is to check the domain name of the site. If the site have google analytics defined it should match the defined "Google Analytics" code for the domain and then print the script to the page.</p>

<p>If the Google Analytics code is not defined it should show nothing!</p>

<pre><code>&lt;?php 
// Get the Domain URL
$analyticsurl = get_site_url();
// Check if domain is defined
if ($analyticsurl == 'http://domain-a.com') {$analyticcode = 'UA-25133920-1'; $analyticsurlname = 'domain-a.com';} // domain-a.com
if ($analyticsurl == 'http://domain-b.com') {$analyticcode = 'UA-25133920-1'; $analyticsurlname = 'domain-b.com';} // domain-b.com
if ($analyticsurl == 'http://domain-c.com') {$analyticcode = 'UA-26990264-1'; $analyticsurlname = 'domain-c.com';} // domain-c.com
if ($analyticsurl == 'http://domain-d.com') {$analyticcode = 'UA-30217571-1'; $analyticsurlname = 'domain-d.com';} // domain-d.com
if ($analyticsurl == 'http://domain-e.com') {$analyticcode = 'UA-25537388-1'; $analyticsurlname = 'domain-e.com';} // domain-e.com
// if domain is defined create Google Analytics Code and insert variables
$analyticscode_1 = "&lt;script type='text/javascript'&gt;
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '".$analyticcode."']);
  _gaq.push(['_setDomainName', '".$analyticsurlname."']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;";
// if URL does not match write nothing
if ($analyticcode == '') {$analyticscode = '';}
// if URL exists set the Google Analytics Code
if ($analyticcode != '') {$analyticscode = $analyticscode_1;}
?&gt;
&lt;?php // write the Analytics code to the page
echo $analyticscode ?&gt;
</code></pre>
