php - Random array output into href -


i new php , kinda new html. making website product of week , have idea can't find out how perform it.

my idea create , array every different product , use array_rand randomly choose one, use cron job run every monday. wish chosen array output put href within button product of week.

am going correctly or being horrifically stupid?

cheers, fynn

you want thing this:

<?php $random_key = rand(0, count($product_array) - 1); $href = $product_array[$random_key]; echo '<a href="'.$href.'"'>product link</a>; ?> 

the above gets random array index between 0 , max possible index array , can use random index specify index want array.

if need product of week not random every time store value above in database , every time run cron delete old value , put in new product of week.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -