Return to Snippet

Revision: 12802
at March 30, 2009 23:26 by kossmoss


Updated Code
function LinkReplacer($text, $link, $new_text)
{
	$quoted_link = preg_quote($link,'/\'');
	$regexp = '/<a [^<]*href=["|\']?'.$quoted_link.'["|\']?[^>]*>.*<\\/a>/ui';
	$text=preg_replace($regexp, $new_text, $text);
	return $text;
}

Revision: 12801
at March 30, 2009 17:20 by kossmoss


Updated Code
function LinkReplacer($text, $link)
{
	$quoted_link = preg_quote($link,'/\'');
	$regexp = '/<a [^<]*href=["|\']?'.$quoted_link.'["|\']?[^>]*>.*<\\/a>/ui';
	$text=preg_replace($regexp,"REPLACE TEXT",$text);
	return $text;
}

Revision: 12800
at March 29, 2009 10:29 by kossmoss


Initial Code
$text=preg_replace('/<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>].*>([^<]*)<\/a>/ui',' <a href="/">Здесь была оригинальная ссылка</a> ',$text);

Initial URL


Initial Description
Affects <A> tags for links starting with $link
Example: LinkReplacer ($text, 'http://www.snipplr.com') affects to
<a href="http://www.snipplr.com">Snipplr</a>
and <a href="http://www.snipplr.com/blog">Snipplr Blog</a>

Initial Title
Replace specified link tag in text

Initial Tags
url, replace

Initial Language
PHP