Home > Mobile >  str_contains returns true, but preg_match returns false
str_contains returns true, but preg_match returns false

Time:04-19

I am getting the HTML code of this website -

https://theatrevazrajdane.bg/творчески-състав/актьори/2

with this code $html = file_get_contents($url)

and then I am running a simple regex which does not work and I have no idea why.

This code output - FALSE

preg_match('/actor/miu', $html);

and this code output - TRUE

str_contains($html, 'actor');

Do you know where it could be the reason I checked the HTML several times. It is the correct HTML.

CodePudding user response:

This page has problems with unicode.

Try preg_match('/actor/mi', $html);

  • Related