check in php html word

This question already has an answer here:

  • How do I check if a string contains a specific word? 37 answers

  • You can use the strpos function which is used to find the occurrence of one string inside other:

    if (strpos($url,'word') !== false) {
        echo 'true';
    }
    

    Source: How do I check if a string contains a specific word in PHP?

    To find a word in a complete webpage use file_get_contents

    $text = file_get_contents('http://www.url.com/');
    echo (stristr ($text, 'word')) ? 'found' : 'not found';
    

    Try like this..

    $url1 = 'www.google.com';
    $url2 = 'www.apple.com';
    $url3 = 'www.microsoft.com';
    $url4 = 'www.asus.com';
    
    $word = 'asus';
    
    if (strpos($url1, $word) !== false && strpos($url2, $word) !== false && strpos($url3, $word) !== false && strpos($url4, $word) !== false) {
        echo "$word Exist";
    }else{
        echo "$word Not Exist";
    }
    

    Hope this will help

    链接地址: http://www.djcxy.com/p/13142.html

    上一篇: 选择名称包含字符php的文件

    下一篇: 检查在PHP的HTML文字