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 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码