trying to set up a simple embed box to echo url and randomize source anchor text. I achieved both with this:
<textarea class="cf" onclick="this.focus();this.select()" readonly="readonly">
<iframe src="<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $url;
?>" width="550px" height="400px" frameborder="0" scrolling="auto" allowtransparency="true"><a href="http://example.com/"><?php
$raAnchor = array(1 => 'example.com',
2 => 'http://example.com/',
3 => 'www.example.com',
4 => 'Click here');
$raNumber = count($raAnchor);
echo $raAnchor[rand(1, $raNumber)];
?></a></iframe>
</textarea>
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:
1 => 'example.com',
2 => 'example.com',
3 => 'example.com',
4 => 'example.com',
5 => 'http://example.com/',
6 => 'www.example.com',
7 => 'Click here');
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.
Thanks.