I can’t seem to add a target to the URL without getting an error :/
Could anyone please be so kind to help out? Thanks!
<?php
echo "<a href=\"".$banner[$random]['link']."\"><img src=\"".$banner[$random]['img']."\" border=\"0\"></a>";
//result
?>
I’ve tried this solution;
echo "<a href=\"".$banner[$random]['link']."\"><img src=\"".$banner[$random]['img']."\" border=\"0\".'" target="_blank"></a>";
This is the full code (it’s a random image + URL script):
<?php
$banner[1]['link'] = "http://www.url.com";
$banner[1]['img'] = "/banners/square_1.jpg";
$banner[2]['link'] = "http://url.com";
$banner[2]['img'] = "/banners/square_2.jpg";
//number of banners
$banners=2;
srand((double)microtime()*1000000);
$random = rand(1,$banners);
echo "<a href=\"".$banner[$random]['link']."\"><img src=\"".$banner[$random]['img']."\" border=\"0\"></a>";
//result
?>
Just use:
I’m a big fan of the curly brackets for readability.
But I’d, personally, do it like:
for even easier readability.