0
function findit($gbq, $kwords){

$original_file = file_get_contents($gbq);

$keytar = $kwords;
$ckeytar = strtoupper($keytar);
$okeytar = strtolower($keytar);

$arrit = array(
    "original" => $keytar,
    "ocap" => $ckeytar,
    "olow" => $okeytar,
);

if(strpos($original_file, $arrit['original']) == true) {
    $fp = fopen("linkter.html", 'a');
    fwrite($fp, "<a href='" . $gbq . "' style='color:orange;'>" . $gbq . "</a>");
    fclose($fp);
}
elseif(strpos($original_file, $arrit['ocap']) == true) {
    $fp = fopen("linkter.html", 'a');
    fwrite($fp, "<a href='" . $gbq . "' style='color:red;'>" . $gbq . "</a>");
    fclose($fp);
}
elseif(strpos($original_file, $arrit['olow']) == true) {
    $fp = fopen("linkter.html", 'a');
    fwrite($fp, "<a href='" . $gbq . "' style='color:green;'>" . $gbq . "</a>");
    fclose($fp);
}
else{
    echo "String not found";
}

}

For some reason it says there is an empty delimiter in the second conditional (the $arrit['ocap'] one).

I've read some other answers, but I haven't found one that works (or that I think would work)

4

1 回答 1

0

当您使用stripos()而不是简化事情时会发生什么strpos(),如下所示:

function findit($gbq, $kwords)
{
    $original_file = file_get_contents($gbq);

    if (stripos($original_file, $kwords) !== false)
    {
        $fp = fopen("linkter.html", 'a');
        fwrite($fp, "<a href='" . $gbq . "' style='color:orange;'>" . $gbq . "</a>");
        fclose($fp);
    }
    else
    {
        echo "String not found";
    }
}
于 2012-05-15T02:07:42.133 回答