$str=file_get_contents("$page"); preg_match_all("/&nbsp;&raquo;&nbsp;<b>Текст:<\/b>(.+?)<BR>&nbsp;&raquo;&nbsp;/", $str, $name); echo "<strong>Текст:</strong>"; echo $name[1][0]; echo "<br>"; 

The problem is that the links on the site have an abbreviated view, like index.php. Therefore, on my website, the same links do not work. How can you replace href = "ssilka.php" with href = "http://www.sait.ru/ssilka.php". Well, or somehow create a page ssilka.php on my website that would redirect to that site and save the _GET method in the link.

    2 answers 2

    How can you replace href = "ssilka.php" with href = "http://www.sait.ru/ssilka.php".

    you can replace it with:

     $pref = "http://www.sait.ru/"; $page = '... Как можно заменить href="ssilka.php" на href="ssilka2.php".'; $page = preg_replace('#href="([a-zA-Z0-9.]+)"#i', 'href="'.$pref.'$1"', $page); echo $page; 

    It will be displayed: ... How can I replace href = " http://www.sait.ru/ssilka.php " with href = " http://www.sait.ru/ssilka2.php ".

      If I understood correctly, then somehow

       $pattern = '/href="([^"]*)"/i'; $replacement = '/href="URL/${1}"'; preg_replace($pattern, $replacement, $YOUR_STRING); 

      Replaces all links in the text.