A
A
Alexander2016-05-30 12:01:56
PHP
Alexander, 2016-05-30 12:01:56

Preg_match does not work with Cyrillic in the template.. Why?

Hello, friends. The second day I'm scratching my head, why doesn't preg_match work?

setlocale(LC_ALL, 'ru_RU.UTF-8');
header('Content-Type: text/html; charset=utf-8');
$out = file_get_contents("http://vseigru.net/igry-testy/19701-igra-gadalka-na-kazhdyj-den.html");
//echo $out;         
preg_match("/<h1>Игра(.*)<\/h1>/u", $out, $tit);
var_dump($tit);

Outputs NULL.
If you make the template preg_match("/(.*)<\/h1>/u", $out, $tit); , then it displays all the rules, only with str_replace the same problem ... Donor site on utf-8

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Grigory Esin, 2016-05-30
@xotey83

Works for me. Under var_dump($tit) do var_dump(preg_last_error());
Show me what it outputs.
What is the encoding of the script?

O
OnYourLips, 2016-05-30
@OnYourLips

Is the script file exactly in UTF-8 encoding?
The PSR-1 standard requires: Files MUST use only UTF-8 without BOM for PHP code .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question