2015-01-05 46 views
-3

我得到是谁的数据,所以有这样的代码为波纹管阵列来读取数据,PHP

<?php 
error_reporting(0); 
header('Content-Type: text/html; charset=UTF-8'); 
$query = $_GET['query']; 
$fast = $_GET['fast']; 
include_once('whois.main.php'); 
include_once('whois.utils.php'); 
$whois = new Whois(); 
$result = $whois->Lookup($query); 
?> 

在这里,我可以通过

<?php 
echo '<pre>'; // This is for correct handling of newlines 
ob_start(); 
var_dump($result); 
echo '</pre>'; 

?> 

看到我的转储数据后,我的转储数据看这样

Array 
(
    [0] => Access to .IN WHOIS information is provided to assist persons in determining the contents of a domain name registration record in the .IN registry database. The data in this record is provided by .IN Registry for informational purposes only, and .IN does not guarantee its accuracy. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to(a) allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the data recipient's own existing customers; or (b) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator, a Registrar, or Afilias except as reasonably necessary to register domain names or modify existing registrations. All rights reserved. .IN reserves the right to modify these terms at any time. By submitting this query, you agree to abide by this policy. 
    [1] => 
    [2] => Domain ID:D9115931-AFIN 
    [3] => Domain Name:WHOISEXTRACTOR.IN 
    [4] => Created On:17-Jan-2015 19:27:40 UTC 
    [5] => Last Updated On:29-Sep-2015 19:29:09 UTC 
    [6] => Expiration Date:17-Jan-2016 19:27:40 UTC 
    [7] => Sponsoring Registrar:GoDaddy.com, LLC (R101-AFIN) 
    [8] => Status:CLIENT DELETE PROHIBITED 
    [9] => Status:CLIENT RENEW PROHIBITED 
    [10] => Status:CLIENT TRANSFER PROHIBITED 
    [11] => Status:CLIENT UPDATE PROHIBITED 
    [12] => Registrant ID:CR185387971 
    [13] => Registrant Name:Shiv Singh Kushwaha 
    [14] => Registrant Organization: 
    [15] => Registrant Street1:Village and Post - Bargarh 
    [16] => Registrant Street2: 
    [17] => Registrant Street3: 
    [18] => Registrant City:Chitrakoot 
    [19] => Registrant State/Province:Uttar Pradesh 
    [20] => Registrant Postal Code:210208 
    [21] => Registrant Country:IN 
    [22] => Registrant Phone:+91.9450987150 
    [23] => Registrant Phone Ext.: 
    [24] => Registrant FAX: 
    [25] => Registrant FAX Ext.: 
    [26] => Registrant Email:[email protected] 
    [27] => Admin ID:CR185387973 
    [28] => Admin Name:Shiv Singh Kushwaha 
    [29] => Admin Organization: 
    [30] => Admin Street1:Village and Post - Bargarh 
    [31] => Admin Street2: 
    [32] => Admin Street3: 
    [33] => Admin City:Chitrakoot 
    [34] => Admin State/Province:Uttar Pradesh 
    [35] => Admin Postal Code:210208 
    [36] => Admin Country:IN 
    [37] => Admin Phone:+91.9450987150 
    [38] => Admin Phone Ext.: 
    [39] => Admin FAX: 
    [40] => Admin FAX Ext.: 
    [41] => Admin Email:[email protected] 
    [42] => Tech ID:CR185387972 
    [43] => Tech Name:Shiv Singh Kushwaha 
    [44] => Tech Organization: 
    [45] => Tech Street1:Village and Post - Bargarh 
    [46] => Tech Street2: 
    [47] => Tech Street3: 
    [48] => Tech City:Chitrakoot 
    [49] => Tech State/Province:Uttar Pradesh 
    [50] => Tech Postal Code:210208 
    [51] => Tech Country:IN 
    [52] => Tech Phone:+91.9450987150 
    [53] => Tech Phone Ext.: 
    [54] => Tech FAX: 
    [55] => Tech FAX Ext.: 
    [56] => Tech Email:[email protected] 
    [57] => Name Server:NS2.WHOISEXTRACTOR.IN 
    [58] => Name Server:NS1.WHOISEXTRACTOR.IN 
    [59] => Name Server: 
    [60] => Name Server: 
    [61] => Name Server: 
    [62] => Name Server: 
    [63] => Name Server: 
    [64] => Name Server: 
    [65] => Name Server: 
    [66] => Name Server: 
    [67] => Name Server: 
    [68] => Name Server: 
    [69] => Name Server: 
    [70] => DNSSEC:Unsigned 
    [71] => 
    [72] => 
) 

所以创建了一个foreach循环,但它不工作,我的代码是

<?php foreach ($result['regrinfo'] as $key => $value) 
{ 
    echo $value['rawdata']; 
} 
?> 

但我有格式化需要它。

Domain Name: SRAPSWARE.COM 
Registry Domain ID: 1628686810_DOMAIN_COM-VRSN 
Registrar WHOIS Server: whois.publicdomainregistry.com 
Registrar URL: www.publicdomainregistry.com 
Updated Date: 2015-12-05T05:37:38Z 
Creation Date: 2010-12-04T10:08:59Z 
Registrar Registration Expiration Date: 2016-12-04T11:08:59Z 
Registrar: PDR Ltd. d/b/a PublicDomainRegistry.com 
Registrar IANA ID: 303 
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited 
Registry Registrant ID: 
Registrant Name: Domain Admin 
Registrant Organization: Privacy Protection Service INC d/b/a PrivacyProtect.org 
Registrant Street: C/O ID#10760, PO Box 16 Note - Visit PrivacyProtect.org to contact the domain owner/operator Note - Visit PrivacyProtect.org to contact the domain owner/operator 
Registrant City: Nobby Beach 
Registrant State/Province: Queensland 
Registrant Postal Code: QLD 4218 
Registrant Country: AU 
Registrant Phone: +45.36946676 
Registrant Phone Ext: 
Registrant Fax: 
Registrant Fax Ext: 
Registrant Email: [email protected] 
Registry Admin ID: 
Admin Name: Domain Admin 
Admin Organization: Privacy Protection Service INC d/b/a PrivacyProtect.org 
Admin Street: C/O ID#10760, PO Box 16 Note - Visit PrivacyProtect.org to contact the domain owner/operator Note - Visit PrivacyProtect.org to contact the domain owner/operator 
Admin City: Nobby Beach 
Admin State/Province: Queensland 
Admin Postal Code: QLD 4218 
Admin Country: AU 
Admin Phone: +45.36946676 
Admin Phone Ext: 
Admin Fax: 
Admin Fax Ext: 
Admin Email: [email protected] 
Registry Tech ID: 
Tech Name: Domain Admin 
Tech Organization: Privacy Protection Service INC d/b/a PrivacyProtect.org 
Tech Street: C/O ID#10760, PO Box 16 Note - Visit PrivacyProtect.org to contact the domain owner/operator Note - Visit PrivacyProtect.org to contact the domain owner/operator 
Tech City: Nobby Beach 
Tech State/Province: Queensland 
Tech Postal Code: QLD 4218 
Tech Country: AU 
Tech Phone: +45.36946676 
Tech Phone Ext: 
Tech Fax: 
Tech Fax Ext: 
Tech Email: [email protected] 
Name Server: ns1.srapsware.com 
Name Server: ns2.srapsware.com 
DNSSEC:Unsigned 
Registrar Abuse Contact Email: [email protected] 
Registrar Abuse Contact Phone: +1-2013775952 
URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ 
>>>Last update of WHOIS database: 2015-12-09T06:41:04+0000Z<<< 
For more information on Whois status codes, please visit https://icann.org/epp 

Registration Service Provided By: RURALSERVER 

PRIVACYPROTECT.ORG is providing privacy protection services to this domain name to 
protect the owner from spam and phishing attacks. PrivacyProtect.org is not 
responsible for any of the activities associated with this domain name. If you wish 
to report any abuse concerning the usage of this domain name, you may do so at 
http://privacyprotect.org/contact. We have a stringent abuse policy and any 
complaint will be actioned within a short period of time. 

The data in this whois database is provided to you for information purposes 
only, that is, to assist you in obtaining information about or related to a 
domain name registration record. We make this information available "as is", 
and do not guarantee its accuracy. By submitting a whois query, you agree 
that you will use this data only for lawful purposes and that, under no 
circumstances will you use this data to: 
(1) enable high volume, automated, electronic processes that stress or load 
this whois database system providing you this information; or 
(2) allow, enable, or otherwise support the transmission of mass unsolicited, 
commercial advertising or solicitations via direct mail, electronic mail, or 
by telephone. 
The compilation, repackaging, dissemination or other use of this data is 
expressly prohibited without prior written consent from us. The Registrar of 
record is PDR Ltd. d/b/a PublicDomainRegistry.com. 
We reserve the right to modify these terms at any time. 
By submitting this query, you agree to abide by these terms. 

所以请帮助我获得格式化的数据

+0

你'ob_start的另一种解决方案()'没有结束'使用ob_flush()' ,也许这是问题... –

+1

我没有收到你请发布整个数组 –

+0

echo $ value ['rawdata'];' – panther

回答

1

$value['rawdata']是另一个数组,它应该是

<?php 

foreach ($result['rawdata'] as $key => $value) { 
    echo $value . '<br>'; 

    /* 
     in $key are keys 0-77, in $value are strings 

     output: 
     'Domain Name: SRAPSWARE.COM' 
     'Registry Domain ID: ' 
     ... 
    */ 
} 

?> 
+0

不能正常工作显示错误**警告**:为foreach()提供的无效参数在65行的/home/hostingsp/public_html/whois/index2.php –

+0

@srapsware:对不起, 'rawdata'与'regrinfo'处于同一个水平 - 我是基于你的问题做出的。它必须是'$ result ['rawdata']',我已经更新了我的答案。 '$ result ['regrinfo']'是一个数组,'$ result ['rawdata']'第二个。我不想要你准确需要的数据。 – panther

2

srapsware你必须使用这个

 foreach ($result as $key => $value) 
     { 
      echo $value; 
       OR 
      echo $result[$key]; 

      } 
+0

不工作其返回阵列 阵列 阵列 –

+0

你可以发布print_r($结果)的结果? –

1

你可以使用下面的结果数组 -

<?php 
if(!empty($result['rawdata'])) 
    { 
     $winfo .= '<pre>'.implode($result['rawdata'],"\n").'</pre>'; 
    } 
    else 
    { 
     $winfo = implode($whois->Query['errstr'],"\n<br></br>"); 
    } 
    echo $winfo; 
?> 

请使用,让我们知道了result..Also PLZ刷新2-3次为u [R使用一个尝试不给结果库。如果你想我可以给你另一种解决方案。

你可以在这个网址检查此

http://easywebtricks.com/demo/phpwhois/whois.php?query=srapsware.com&output=normal

,或者可以使用这个网址

http://easywebtricks.com/demo/whois/