Как извлечь данные объекта в объекте в php? - PullRequest
0 голосов
/ 19 марта 2019

Мне нужно получить данные результата "vaild" под объектом проверки.Эта строка (["result"] => string (5) "valid").Похоже, что это объект внутри объекта, и я не могу найти синтаксис, как получить доступ к данным в нем.

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) { 
                } 
            } 
        } 
    } 
} 

Данные, которые мне нужны, находятся в этой части кода:

["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" 
                    } 

Я могу получить электронное письмо из данных, используя это:

$object->results[$counter]['data']['email']

1 Ответ

0 голосов
/ 20 марта 2019

Я понял это:

$object->results[$counter]['verification']->result
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...