Anybody have a regular expression to replace the following code:
<a href="originalLink">hi</a>
with:
<a href="newLink">hi</a>
Anybody have a regular expression to replace the following code:
<a href="originalLink">hi</a>
with:
<a href="newLink">hi</a>
PHP Simple HTML Dom Parser example:
// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');
// Find all links
$anchors = $html->find('a');
$count = count($anchors);
for($i=0;$i<$count;$i++) {
$anchors[$i]->href = 'someLink.html';
}
If you know the href
of the anchor you want to replace, do something like:
$html->find('a[href=something]', 0)->href = 'someLink.php';