How to show a specific keyword in an article randomly
<p>I have a keyword "Keyword1" and I have an atricle with "keyword1" appearing several times in it. Each of the "Keyword1" in the article is a link leading to different websites.
So I am trying to randomly show one "keyword1" everytime I refresh the page.</p>

<p>So far I have tried this using stripos() like this.</p>

<pre><code>$needle = "keyword1";
$haystack = 'this is an article with [keyword1] appearing seral times with different links. [Keyword1] blahblah [keyword1]' ;

if(stripos($haystack, $needle) !== false){


$links = $haystack;
$links_to_array = explode(" ", $links);
$randomize = array_rand($links_to_array, 1);
echo ($links_to_array[$randomize]);
}
</code></pre>

<p>SO when I do this... it does not pick one of the keyword1, it also shows a word in the article randomly. You can copy the code and try it for yourself by refreshing your page.</p>

<p>I only want a random keyword1 to be shown.</p>

<p>How can I do this thanks.</p>
