I want to get the source of some website, and search through it to find a string. I did something like this:
$source = file_get_contents('http://website.com');
preg_match('/foobar/', $source, $match);
var_dump($match);
The source contains the expression I look for, dumping $source
variable proves that. But the result is an empty array.
The thing is that everything works, and the result is correct, when I copy the source, and paste it like this:
$source = <<<EOF
// paste here
EOF;
preg_match('/foobar/', $source, $match);
var_dump($match);
Now it works perfectly.
What is wrong, why it happens? Thanks!