Parsing text within iframe

How do I parse a text string on a web page with an iframe? The string is within the iframe.

What I am trying to do is determine whether the iframe is properly loading. Then if it is not write a timestamp and error message to the disk.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

gemdeals395Connect With a Mentor Commented:
Are you wanting to test a remote page from your script? If your wanting to test like that just use preg_match() like this:

$iframe = array();

$url = '';

$ch_one = curl_init();
curl_setopt($ch_one, CURLOPT_URL, $url);
curl_setopt($ch_one, CURLOPT_REFERER, '');
curl_setopt($ch_one, CURLOPT_HEADER, 1);
curl_setopt($ch_one, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch_one, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch_one, CURLOPT_TIMEOUT, 5);
$result_one = curl_exec($ch_one);

preg_match("/<iframe>(.*?)'</iframe>/", $result_one, $iframe);

//Now $iframe is an array and your parsed result of everything between the <iframe> tags is stored in the array location [1]. You can now run tests againts this such as this.

if (strlen($iframe[1] == '0') {
    //nothing was loaded , do something. Now to make sure you didnt get a partial load or anything it would probably be a good idea to keep a cache copy of the html to compare against stored on your end that gets updated every so often and compare what was loaded like so.
} elseif ($iframe[1] != $url.cache) {
    //What was loaded did not match what we expected. Do something.

Maybe that will point you in the right direction. :)
Please littlebit explain more about your problem with iframe and then we will definitely give you the appropriate solution of code.

All Courses

From novice to tech pro — start learning today.