fork download
  1. <?php
  2.  
  3. $html = '<img src="http://s...content-available-to-author-only...k.com/img.jpg"> http://s...content-available-to-author-only...k.com';
  4. $link = preg_replace('%<img src="(.*)/(.*?)">\s*(.*?)\s*$%m', '<img src="$1/$2"> <a href="$1" target="_blank">$3</a>', $html );
  5. echo $link;
  6.  
  7.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<img src="http://s...content-available-to-author-only...k.com/img.jpg"> <a href="http://s...content-available-to-author-only...k.com" target="_blank">http://s...content-available-to-author-only...k.com</a>