Per cercar números random amb php:
<?
$nombremaxim = 3;
$random = rand(1, $nombremaxim);
?>
Aquest random és millorable amb el següent codi:
<?
$nombremaxim = 3;
$random = rand(1, $nombremaxim);
$img = array();
$url = array();
$txt = array();
$img[1] = “arxius/imatge_1.gif”;
$url[1] = “http://www.enllaç1.com”;
$txt[1] = “Visita l’enllaç de la imatge 1″;
$img[2] = “arxius/imatge_2.gif”;
$url[2] = “http://www.enllaç2.com”;
$txt[2] = “Visita l’enllaç de la imatge 2″;
$img[3] = “arxius/imatge_3.gif”;
$url[3] = “http://www.enllaç3.com”;
$txt[3] = “Visita l’enllaç de la imatge 3″;
echo “<a href=’$url[$random]‘ target=’_blank’><img src=’$img[$random]‘ alt=’$txt[random]‘ border=’0′></a>”;
?>