i get an website html data .and i need to change all the links to remote website..
like if i have an link <a href="/search?"> i need to change to <a href="http://google.com/search?">
views:
25answers:
1
+1
A:
Perhaps you can just get away with a simple:
<head>
<base href="http://google.com/" />
</head>
Else, you can do some simple match and replace:
<?php
$html = strtr($html, array('href="' => 'href="http://www.google.com/', ... ));
?>
The two big ones are src and href. You may need to do double quotes and single quotes.
If you want to be (mostly) sure to only match inside tags and only relative URLs, you'll need to use regular expressions (and I'm sure somebody will give you some examples).
konforce
2010-02-03 06:59:52