Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 14th, 2012  |  syntax: None  |  size: 1.74 KB  |  views: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. http://www.sitea.com/vip:  => http://localhost/aaa?search=
  2. http://www.sitea.com/      => http://localhost/bbb/ (without 'vip:')
  3. http://www.siteb.com/      => http://localhost/ccc/
  4.        
  5. $str='<a href="http://www.sitea.com/vip:vp_14098">link A</a><a href="http://www.sitea.com/contact">link B</a><a href="http://www.siteb.com/player">link C</a>';
  6. if(strpos($str,'www.sitea.com')!== false){
  7.     if(strpos($str,'vip:')!== false){
  8.         $str = str_replace('http://www.sitea.com/', 'http://localhost/aaa?search=',$str);
  9.     }else{
  10.         $str = str_replace('http://www.sitea.com/', 'http://localhost/bbb/',$str);
  11.     }
  12. }
  13. if(strpos($str,'www.siteb.com')!== false){
  14.     $str = str_replace('http://www.siteb.com/', 'http://localhost/ccc/',$str);
  15. }
  16. echo $str;
  17.        
  18. <a href="http://localhost/aaa?search=vip:vp_14098">link A</a>
  19. <a href="http://localhost/aaa?search=contact">link B</a>
  20. <a href="http://localhost/ccc/player">link C</a>
  21.        
  22. $str='<a href="http://www.sitea.com/vip:vp_14098">link A</a><a href="http://www.sitea.com/contact">link B</a><a href="http://www.siteb.com/player">link C</a>';
  23. $str = str_replace('http://www.sitea.com/vip:', 'http://localhost/aaa?search=vip:',$str);
  24. $str = str_replace('http://www.sitea.com/', 'http://localhost/bbb/',$str);
  25. $str = str_replace('http://www.siteb.com/', 'http://localhost/ccc/',$str);
  26. echo $str;
  27.        
  28. <?php
  29.     $str='<a href="http://www.sitea.com/vip:vp_14098">link A</a><a href="http://www.sitea.com/contact">link B</a><a href="http://www.siteb.com/player">link C</a>';
  30.     $str = str_replace('http://www.sitea.com/vip:', 'http://localhost/aaa?search=',$str);
  31.     $str = str_replace('http://www.sitea.com/', 'http://localhost/bbb/',$str);
  32.     $str = str_replace('http://www.siteb.com/', 'http://localhost/ccc/',$str);
  33.     echo $str;
  34. ?>
clone this paste RAW Paste Data