JPDP
JPDP

Reputation: 199

Multiple Strpos checks

Would there be anyway to merge the below queries into a single function? As it stands only the second Strpos function works. If i remove the second one then the first one will work. I need to run both as I have to check for 2 separate strings.

$check1 = QueryWhoisServer($whoisserver, $domain);
if(strpos($check1,"No match for") !== FALSE){

return "Result Example";
}
$check2 = QueryWhoisServer($whoisserver, $domain);
if(strpos($check2,"No Data Found") !== FALSE){

return "Result 2 example";
}
else {

Any help would be much appreciated.

Upvotes: 2

Views: 325

Answers (1)

Ja͢ck
Ja͢ck

Reputation: 173562

First of all, you should keep the output of your whois query.

$response = QueryWhoisServer($whoisserver, $domain);

Then, you can run multiple searches:

if (false !== strpos($response, 'No match for')) {
  // ...
} elseif (false !== strpos($response, 'No Data Found')) {
  // ...
} else {
  // ...
}

Upvotes: 1

Related Questions