-5
{"Dina-Kar":{"com":"available"},"DinaKarPool":{"com":"available"},"DinaKarStore":{"com":"available"},"DinaKarOnline":{"com":"available"},"DinaKarParts":{"com":"available"},"DinaKarJack":{"com":"available"},"DinaKarTunes":{"com":"available"},"DinaKarSmart":{"com":"available"},"DinaKarWash":{"com":"available"},"DinaKarRound":{"com":"available"}}

Dina-Kar.com が利用可能であるため、出力が必要です。また、使用可能なすべての値に対して、PHP スクリプトを使用して動的にループを実行する必要があります。

その出力のように私を助けてくれませんか。

4

1 に答える 1

0

コードパッドでライブ

クラス:

class DomainChecker
{
  private $domains;

  public function __construct( $domainlist )
  {
    $this->domains = json_decode( $domainlist );
  }

  public function Exists( $domain, $tld )
  {
    return 
       isset($this->domains->$domain) && 
       isset($this->domains->$domain->$tld) && 
       $this->domains->$domain->$tld != 'available';
  }

  public function ListAll()
  {
    $result = '';
    foreach($this->domains as $domainname => $domain)
      foreach($domain as $tldname => $tld)
         $result .= "$domainname.$tldname\t$tld\n";
    return $result;
  }
}

使用法:

$domainchecker = new DomainChecker('{"Dina-Kar":{"com":"available"},"DinaKarPool":{"com":"available"},"DinaKarStore":{"com":"available"},"DinaKarOnline":{"com":"available"},"DinaKarParts":{"com":"available"},"DinaKarJack":{"com":"available"},"DinaKarTunes":{"com":"available"},"DinaKarSmart":{"com":"available"},"DinaKarWash":{"com":"available"},"DinaKarRound":{"com":"available"}}');

$domain = 'Pome-Tek';
$tld = 'com';

if( $domainchecker->Exists( $domain, $tld ))
  echo "$domain.$tld is not available\n\n";
else
  echo "$domain.$tld is available\n\n";

echo $domainchecker->ListAll();

出力:

Pome-Tek.com is available

Dina-Kar.com    available
DinaKarPool.com available
DinaKarStore.com    available
DinaKarOnline.com   available
DinaKarParts.com    available
DinaKarJack.com available
DinaKarTunes.com    available
DinaKarSmart.com    available
DinaKarWash.com available
DinaKarRound.com    available
于 2012-10-27T10:02:57.113 に答える