There is a task to take the file "robots.txt" from the address specified by the user, and find in it the number of directives "Host". The file "robots.txt" for example -
User-agent: Yandex Disallow: / host: example.com host: example2.com I take the file from the remote server at the user's request and the character encoding can be any. In order not to be attached to the case of characters I try to do this:
$url = 'http://tests.loc/robots.txt'; $maxsize = 32768; $ctx = stream_context_create(array('http' => array('timeout' => 10))); $directives = file_get_contents($url, false, $ctx, -1, $maxsize); setlocale(LC_ALL, "en_US.UTF-8"); echo strtolower($directives); //Возвращает ту же строку без изменения регистра символов echo substr_count($directives, 'host'); Tell me what's wrong? Or maybe this problem can be solved otherwise.
{}button means inserting the code. Please use it. - Naumov