There is the following script:

$output = file_get_contents('http://ru.heroquizz.com/t/zpa254ylg4'); echo preg_replace('/^yii2.co75701.tmweb.ru$/', "ru.heroquizz.com", $output); 

There should be a link replacement, but it does not occur. Why?

    1 answer 1

    the point - in the regular expression is any character. right:

     echo preg_replace('/yii2\.co75701\.tmweb\.ru/', "ru.heroquizz.com", $output); 

    although on the page http://ru.heroquizz.com/t/zpa254ylg4 I didn’t find yii2.co75701.tmweb.ru ...

    Perhaps you need the opposite:

     echo preg_replace('/ru\.heroquizz\.com/', "yii2.co75701.tmweb.ru", $output); 
    • And I use on my page. and still - not replaced ... - Timur Musharapov
    • @TimurMusharapov just made $ output = file_get_contents (' en.heroquizz.com/t/zpa254ylg4' ); echo preg_replace ('/ en \ .heroquizz \ .com /', "yii2.co75701.tmweb.ru", $ output); everything works .... i.e. all ru.heroquizz.com replaced by yii2.co75701.tmweb.ru - Alex