dppfxf909679 2019-03-19 18:44
浏览 75
已采纳

如何在php中解析出这个对象/数组?

I have an object I need to parse out and insert into SQL but I am having a hard time figuring out what I need to do as far as the order of fields in the syntax listed below.

Here is the object vardump:

object(EmailCheck\Object\ResponseObject)#25 (1) { 
    ["response":protected]=> array(6) { 
        ["status"]=> string(7) "success" 
        ["total_results"]=> int(6) 
        ["total_pages"]=> int(1) 
        ["query"]=> array(8) { 
            ["job_id"]=> int(2562625) 
            ["valids"]=> int(1) 
            ["invalids"]=> int(1) 
            ["disposables"]=> int(1) 
            ["catchalls"]=> int(1) 
            ["unknowns"]=> int(1) 
            ["page"]=> int(0) 
            ["items_per_page"]=> int(10) 
        } 
        ["results"]=> array(6) { 
            [0]=> array(2) {     
                ["data"]=> array(4) { 
                    ["email"]=> string(20) "chris@example.com" 
                    [0]=> string(1) "1" 
                    ["ID"]=> string(1) "1" 
                    ["EMAIL"]=> string(20) "chris@example.com" 
                    } 
                ["verification"]=> object(EmailCheck\Object\VerificationObject)#7 (1) { 
                    ["response":protected]=> array(7) { 
                        ["result"]=> string(5) "valid" 
                        ["flags"]=> array(3) { 
                            [0]=> string(7) "has_dns" 
                            [1]=> string(10) "has_dns_mx" 
                            [2]=> string(16) "smtp_connectable" 
                        } 
                ["suggested_correction"]=> string(0) "" 
                ["address_info"]=> object(EmailCheck\Object\ResponseObject)#9 (1) { 
                    ["response":protected]=> array(9) { 
                        ["original_email"]=> string(20) "chris@example.com" 
                        ["normalized_email"]=> string(20) "chris@example.com" 
                        ["addr"]=> string(6) "chris" 
                        ["alias"]=> string(0) "" ["host"]=> string(13) "example.com" 
                        ["fqdn"]=> string(13) "example.com" 
                        ["domain"]=> string(9) "example" 
                        ["subdomain"]=> string(0) "" 
                        ["tld"]=> string(3) "com" 
                    } 
                } 
                ["email"]=> string(20) "chris@example.com 
                ["result_integer"]=> int(0) 
                ["credits_info"]=> object(EmailCheck\Object\ResponseObject)#8 (1) { 
                    ["response":protected]=> array(0) { 
                } 
            } 
        } 
    } 
} 

I know the syntax is something like this but it is not returning anything:

echo $object->data->email;

I need to extract the following fields: result, normalized_email, email

  • 写回答

1条回答 默认 最新

  • douyou2368 2019-03-19 19:59
    关注

    This is what ended up working. I did not need to reference the "response" portion of the object.

    $object->results[0]['data']['email']
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?