If i download a page using file_get_contents()
and the result it's like this
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="no-cache">
<link href="/style.css?q=245f90373d16694462b99d01a6a3eac8" rel="stylesheet" type="text/css">
<script type='text/javascript' src='/page?lang=en'></script>
</head>
<body>
<a href="/page?q=245f90373d16694462b99d01a6a3eac8"></a>
<a href="./page?q=245f90373d16694462b99d01a6a3eac8"></a>
<a href="http://example.com/page?q=245f90373d16694462b99d01a6a3eac8"></a>
<a href="https://example.com/page?q=245f90373d16694462b99d01a6a3eac8"></a>
</body>
[...]
</html>
I need a function that converts every href
and src
to http://example2.org/*
Note that there are quotes "
but also '
A not difficult way to do it like preg_replace()
?