This might be a little complicated..!
Here’s what I got so far:
$i = 0;
foreach ($posts as $post) {
$link = $post[1];
$title = $post[2];
$i++;
//echo $link;
}
$i = Counts all posts on my website.
$link = provide a link to the post.
After fetching how many posts I have with $i, I need to randomize a value between 1-“Total Posts” and instead of echoing out the random value it should redirect the website to the respective $link. Can someone please enlighten me?
You can use the function array_rand to obtain a random key in
$postsIf you have a fetish for one-liners
header("Location: ".$posts[array_rand ($posts)][1]);