使用PHP打开HTML和JS文件并搜索特定关键字

I am writing a little script that distinguishes between responsive ads banner and non responsive ones. I need to scan the HTML and JS Files of these banner for the following Keywords: Android,Iphone and return true or false if something is found.

$fileinfos = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory)
);
foreach ($fileinfos as $pathname => $fileinfo) {
if (!$fileinfo->isFile()) continue;
//var_dump($pathname);
$files[] = $pathname;
}

$array_count = count($files); //Counts all elements of the array - will 
be used for the loop

$info = array();
$match_files = array();
$index_match = 0;

for ($i = 0; $i < $array_count; $i++) {
    //echo "<br>" . $files[$i];

$info[$i] = pathinfo($files[$i]);

if ($info[$i]['extension'] == 'html' || $info[$i]['extension'] == 'js') 
{
    //echo $info[$i]['dirname']. "/" . $info[$i]['basename']. "<br>";
    $match_files[$index_match++] = $info[$i]['dirname'] . "/" . 
$info[$i]['basename'];

}


}

This code returns the path of the html and js files of a specific folder in an Array. Now I want to scan these files for the above mentioned Keywords. I hope you can help me out here, it really makes me an headache.

Peace and regards Al

Just store the entire file in a string. Use strpos passing in the file and the keyword you are looking, it will return false if it's not found, or the index in the string where it was found. You can use that index to do some further analysis of the keyword to make sure it's not in a comment for example.

http://php.net/manual/en/function.strrpos.php