Guest User

alt

a guest
May 23rd, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. $linkArray = array(
  3. 'http://google.com/',
  4. 'https://google.com'
  5. );
  6. $strings = '';
  7. foreach($linkArray as $link) {
  8. $strings .= $link.' ';
  9. }
  10. $article = "hello ".$strings." everyone" ;
  11. $parts = explode(" ", $article);
  12. $randomamount = count($parts);
  13. $hit = rand(0, $randomamount);
  14. $temp = $parts[$hit];
  15. if(stristr($temp, "http:") or stristr($temp, "https:")) {
  16. foreach($linkArray as $link) {
  17. if(stristr($temp, $link)) {
  18. $temp = str_replace($link, "<a href='".$link."'>".$link."</a>", $temp);
  19. }
  20. }
  21. }
  22. if(isset($_SESSION['last'])) {
  23. // already seen?ok
  24. if($hit == 0) {
  25. $hit=$hit+1;
  26. } else {
  27. $hit=$hit-1;
  28. }
  29. }
  30. $_SESSION['last']=$hit;
  31. echo $temp;
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment