mardi 4 août 2015

Preg_Match PHP Script not working

I have been referring to the PHP Manual and other sites to build this but cannot seem to get it working even though I have checked the source of the site that contains a link to externally hosted jquery file by Google so a match should be found.

I did check the regex to make sure it correctly picks up script links within the HTML but it just does not want to match it with the $sign (Signatures) that I am hoping it would match.

$regex = "/<script.+src=\"(.+)\"><\/script>/i";
$site = file_get_contents("http://ift.tt/18qQonn");
$sign = 'jquery';
$sign = 'jQuery v2.1.3';

if (preg_match($regex, $site, $sign)) {
    echo 'A match was found.';
} else {
    echo 'A match was not found. boo boo';
}

What am i doing wrong could you please advise? Thanks for your help in advanced.

Aucun commentaire:

Enregistrer un commentaire