ipbfuck Posted April 24, 2016 Posted April 24, 2016 Hi, i've used an Advertisement by ad key in template, and i need to make a random image in this, same url. i've try to make another ad with same link and different image, but how i can put randon php code with {advertisement="key"} in template? something like this: {{ rand(0, 1) ? '{advertisement="key1"}' : '{advertisement="key2"}'; }} (untested - just idea...) - i need equivalent in php for ipb: {advertisement="key"}
ipbfuck Posted April 24, 2016 Author Posted April 24, 2016 Php script: eg > random_image.php put image with name image1.jpg; image2.jpg (if u have more, insert in array) <?php // random jpg from this folder header ("Content-Type: image/jpg"); $images = array ( "image1", "image2" ); include($images[array_rand($images)].".jpg"); ?> html code in advert: <a href="..." title="link title"> <img src="...fulllink/dir_with_image/random_image.php" alt="alternative text"> </a> work as expected! yes, i can use also glob, but glob at every refresh... i think a simple rand - for no more image - can be a best solution regards!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.