Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $linkArray = array(
- 'http://google.com/',
- 'https://google.com'
- );
- $strings = '';
- foreach($linkArray as $link) {
- $strings .= $link.' ';
- }
- $article = "hello ".$strings." everyone" ;
- $parts = explode(" ", $article);
- $randomamount = count($parts);
- $hit = rand(0, $randomamount);
- $temp = $parts[$hit];
- if(stristr($temp, "http:") or stristr($temp, "https:")) {
- foreach($linkArray as $link) {
- if(stristr($temp, $link)) {
- $temp = str_replace($link, "<a href='".$link."'>".$link."</a>", $temp);
- }
- }
- }
- if(isset($_SESSION['last'])) {
- // already seen?ok
- if($hit == 0) {
- $hit=$hit+1;
- } else {
- $hit=$hit-1;
- }
- }
- $_SESSION['last']=$hit;
- echo $temp;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment