PHP - Reemplazar contenido de tag A


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*
  2. In
  3. $Link: URL completa
  4. $str: String que reemplazara al actual valor encerrado en <a></a>
  5. */
  6. function tuFuncion($link, $str){
  7. if( ! empty( $link ) )
  8. return ereg_replace(">([^>]+)</a>", ">".$str."</a>", $link);
  9. else
  10. return false;
  11. }
  12. $link = '<a href="http://www.dominio.com/talcosa" target="_blank">Este texto </a>';
  13. echo tuFuncion($link, "Por este texto");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.