数组到PHP中的可读数据

时间:2015-01-05 11:09:59

标签: php mysql arrays

我知道谁是数据,因此代码如下所示

<?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:support@whoisextractor.in
    [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:support@whoisextractor.in
    [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:support@whoisextractor.in
    [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: contact@privacyprotect.org
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: contact@privacyprotect.org
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: contact@privacyprotect.org
Name Server: ns1.srapsware.com
Name Server: ns2.srapsware.com
DNSSEC:Unsigned
Registrar Abuse Contact Email: abuse-contact@publicdomainregistry.com
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.

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

3 个答案:

答案 0 :(得分:2)

srapsware你必须使用这个

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

          }

答案 1 :(得分: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: '
        ...
    */
}

?>

答案 2 :(得分:1)

您可以使用如下所示的结果数组 -

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

请使用这个,让我们知道结果。另外plz刷新2-3次,因为你使用的库没有给出一次尝试的结果。如果你想我可以给你另一个解决方案。

您可以在此网址上查看此内容

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

或者可以使用此网址的其他解决方案

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