Advertisement
Ruven

Kfir THE KING

Aug 9th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. function retUrls($str){
  2.     $motek = array();
  3.     $c = substr_count($str,'http://');
  4.     while(strpos($str,'http://') !== false){
  5.         $m = strpos($str,'http://');
  6.         $sub = mb_substr($str,$m);
  7.         $n1 = findSpace($sub);
  8.         $n = getA($n1);
  9.         $str = str_replace($n1,$n,$str);
  10.     }
  11.     $str = str_replace('http::','http:',$str);
  12.     return $str;
  13. }
  14. function findSpace($s){
  15. $p = explode(' ',$s);
  16. return $p[0];
  17. }
  18. function getA($a){
  19.     $a = str_replace('http:','http::',$a);
  20.     return '<a href="'.$a.'">'.$a.'</a>';
  21. }
  22. echo retUrls("motek motek http://bobo.com boboi http://mongol.com sdfsdfa");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement