i'm creating this banner rotating PHP script (I'm new to PHP) and was wondering why my cases aren't working. I can get the random image to show via the array although I can't seem to make the cases work.
I would like it so if the image from the random array is the 0 image, it will say visit jackhair.co.uk and if the random image from the array is 2 it will say jamiehair.co.uk
<?php
/*Creates an array called banners which holds all the images of banners */
$banners=array("img/reversessh.jpg","img/failtwo.jpg","img/iptable.jpg");
$random = ($banners[(rand(0,2))]);
$visit = $random;
switch($visit)
{
case $visit = 0:
Echo "Visit www.jackhair.co.uk";
break;
case $visit = 1:
Echo "Visit www.lukehair.co.uk";
break;
case $visit = 2:
Echo "Visit www.jamiehair.co.uk";
break;
default:
null;
}
?>
<img src="<?= $random ?>" alt="Rotating Banners" />
Hope you can help! Thankyou.