Hi, I am working on a PHP file and need it to open a URL and if there is a certain word or phrase on the web page then open a second URL. If the text is not there, then I need the first URL to continually open until the text is found. I would imagine this is pretty simple, something like an IF statement and a loop somewhere. But how do I do this? Any help would be greatly appreciated!
$link = "www.example.com"; $content = file_get_contents($link); $needle = "<div>find string</div>"; if (strpos($content, $needle) === false) { header("Location: my_page.php"); } else { echo "String found"; } PHP: It may help you. Let me know.
Thanks for your response. I tried it - and it seems to load the 2nd page OK (my_page.php) but it doesn't seem to be loading it on the condition that it finds the "find string" text first, it just seems to run anyway?
ldigital mixed up the conditions a little, use the following: $link = "www.blahblah.com"; $content = file_get_contents($link); $needle = "<div>find string</div>"; if (strpos($content, $needle) === false) { //if it does not find the string, display the following echo "String found"; } else { //else it found the string so proceed to the page header("Location: my_page.php"); } Good luck!