1

How do I find the content "Please enter a valid key again" using Simple HTML DOM Parser?

Example:

<script language="javascript">
     function Enable() {      
        alert('Please enter a valid key again');
     }
</script>

This don't seem to work:

<?php

include_once("simple_html_dom.php");

$html = file_get_html("incorrect.html");

$ret = $html->find("Please enter a valid key again", 0);

if ($ret) {
    echo "found";
} else {
    echo "not found";
}
?>
1
  • I don't use that, but wouldn't it be more simple and faster, because its using compiled code, to use DOMDocument? Then you can just do a $doc->getElementsByTagName("script"); ? or since you seem to be just doing a string search? using preg_match or strpos() to search for it in the html string data? Commented Jun 30, 2011 at 23:20

1 Answer 1

4

You can do this in a simpler way:

<?php    
include_once("simple_html_dom.php");        
$html = file_get_html('incorrect.html');
(strstr($html,'Please enter a valid key again')) ? print("found") : print("not found");
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.