Mega Code Archive

 
Categories / Php / Strings
 

Replace the tag content without getting rid of any attributes

<?php      $string = "<a href=\"http://www.rntsoft.com/\">rntsoft.com</a><br />" ;          $pattern = '/<a(.*?)>.*?<\/a>/i';      $replacement = '<a\1>Click!</a>';          $string = preg_replace($pattern, $replacement, $string);      print($string); ?>