PHP- weighted array for random anchor text
<p>trying to set up a simple embed box to echo url and randomize source anchor text. I achieved both with this:</p>

<pre><code>&lt;textarea class="cf" onclick="this.focus();this.select()" readonly="readonly"&gt;
&lt;iframe src="&lt;?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url;
?&gt;" width="550px" height="400px" frameborder="0" scrolling="auto" allowtransparency="true"&gt;&lt;a href="http://example.com/"&gt;&lt;?php 
$raAnchor = array(1 =&gt; 'example.com', 
           2 =&gt; 'http://example.com/', 
           3 =&gt; 'www.example.com', 
           4 =&gt; 'Click here');  
$raNumber = count($raAnchor); 
echo $raAnchor[rand(1, $raNumber)]; 
?&gt;&lt;/a&gt;&lt;/iframe&gt;
&lt;/textarea&gt;
</code></pre>

<p>The problem: how do I weight random results from the array to favor a particular echo? For example, would like example.com to echo out 50% of the time. 
I guess I could just put more example.com in the array like this:</p>

<pre><code>1 =&gt; 'example.com', 
2 =&gt; 'example.com', 
3 =&gt; 'example.com', 
4 =&gt; 'example.com', 
5 =&gt; 'http://example.com/', 
6 =&gt; 'www.example.com', 
7 =&gt; 'Click here');  
</code></pre>

<p>Seems there has to be a more elegant solution. I'm new to programming, and php I understand the least so if you could point me in the right direction I can take it from there. </p>

<p>Thanks.</p>
