Elliot Reed
Elliot Reed

Reputation: 749

PHP If iFrame contains certain string then display (or do not display)

In PHP / HTML I have an iFrame which displays contents from an external website (not my own). Basically I need to be able to only have that iFrame displayed if it doesn't contain the words "No Details Found". Is this possible?

echo '<li><iframe src="http://web.site.co.uk/wrd/run/wt_xtest_pw.cb_cgi?cb_dialogue=detailSearch&MyRef=$_GET[useforminput]&contactNo=0123456789" width="188" height="258" scrolling="no" style="overflow:hidden; margin-top:-4px; margin-left:-4px; border:none;"></iframe></li>';

Where $_GET[useforminput] is the variable (I assume that bit's fine, even with quotes, etc.)

So I need that iFrame to not display if it contains "No Details Found". It's a bit of a useless API from a company who doesn't appear to like XML very much..

Upvotes: 0

Views: 700

Answers (1)

paranoid
paranoid

Reputation: 535

$var = file_get_contents('http://web.site.co.uk/wrd/run/wt_xtest_pw.cb_cgi?cb_dialogue=detailSearch&MyRef='.$_GET['useforminput'].'&contactNo=0123456789');

if( strpos($var, 'No Details Found') === false ) {

    // not found, display
} else {

    // found, do something else
}

Upvotes: 1

Related Questions