Вывод информации из объекта PHP

109
26 октября 2019, 17:00

Есть такой код:

Array
(
    [1] => pm_Domain Object
        (
            [_domainId:pm_Domain:private] => 1
            [_domain:pm_Domain:private] => Domain Object
                (
                    [dz:protected] => 
                    [_hasOwnDnsZoneBeforeUpdate:Domain:private] => 1
                    [domainUser:protected] => 
                    [_forceNew:protected] => 
                    [_webspace:Domain:private] => 
                    [oldTurnOffAction] => 
                    [attr] => Array
                        (
                            [id] => 1
                            [name] => amazonaws.click
                            [displayName] => amazonaws.click
                            [cr_date] => 2019-02-26
                            [status] => 0
                            [webspace_status] => 0
                            [dns_zone_id] => 1
                            [htype] => vrt_hst
                            [cl_id] => 2
                            [vendor_id] => 1
                            [webspace_id] => 0
                            [parentDomainId] => 0
                            [cert_rep_id] => 0
                            [real_size] => 0
                            [guid] => ecc43a4e-0938-40c6-b176-e2ade13dcc14
                            [external_id] => 
                            [adminDescription] => 
                            [resellerDescription] => 
                            [description] => 
                            [overuse] => false
                            [icpStatus] => 0
                            [icpPermit] => 
                        )
                    [_changableAttr:cObject:private] => 
                    [oldAttr_] => Array
                        (
                            [id] => 1
                            [name] => amazonaws.click
                            [displayName] => amazonaws.click
                            [cr_date] => 2019-02-26
                            [status] => 0
                            [webspace_status] => 0
                            [dns_zone_id] => 1
                            [htype] => vrt_hst
                            [cl_id] => 2
                            [vendor_id] => 1
                            [webspace_id] => 0
                            [parentDomainId] => 0
                            [cert_rep_id] => 0
                            [real_size] => 0
                            [guid] => ecc43a4e-0938-40c6-b176-e2ade13dcc14
                            [external_id] => 
                            [adminDescription] => 
                            [resellerDescription] => 
                            [description] => 
                            [overuse] => false
                            [icpStatus] => 0
                            [icpPermit] => 
                        )
                    [errorAttr] => Array
                        (
                        )
                    [reqAttr] => Array
                        (
                            [0] => id
                            [1] => name
                        )
                    [Table] => DomainTable Object
                        (
                            [tables] => Array
                                (
                                    [0] => domains
                                )
                            [fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                    [2] => displayName
                                    [3] => cr_date
                                    [4] => status
                                    [5] => webspace_status
                                    [6] => dns_zone_id
                                    [7] => htype
                                    [8] => cl_id
                                    [9] => vendor_id
                                    [10] => webspace_id
                                    [11] => parentDomainId
                                    [12] => cert_rep_id
                                    [13] => real_size
                                    [14] => guid
                                    [15] => external_id
                                    [16] => adminDescription
                                    [17] => resellerDescription
                                    [18] => description
                                    [19] => overuse
                                    [20] => icpStatus
                                    [21] => icpPermit
                                )
                            [primaryKeys:protected] => Array
                                (
                                    [id] => 2
                                )
                            [prefetchedRow:protected] => 
                            [id] => 1
                            [idAttrIndex] => 0
                            [where] => 
                            [order] => 
                            [result] => Zend_Db_Statement_Pdo Object
                                (
                                    [_fetchMode:protected] => 2
                                    [_stmt:protected] => PDOStatement Object
                                        (
                                            [queryString] => select `id`, `name`, `displayName`, `cr_date`, `status`, `webspace_status`, `dns_zone_id`, `htype`, `cl_id`, `vendor_id`, `webspace_id`, `parentDomainId`, `cert_rep_id`, `real_size`, `guid`, `external_id`, `adminDescription`, `resellerDescription`, `description`, `overuse`, `icpStatus`, `icpPermit` from `domains` where `id`=1
                                        )
                                    [_adapter:protected] => Db_Adapter_Pdo_Mysql Object
                                        (
                                            [_callbackCustomWarningNotification:protected] => 
                                            [_pdoType:protected] => mysql
                                            [_numericDataTypes:protected] => Array
                                                (
                                                    [0] => 0
                                                    [1] => 1
                                                    [2] => 2
                                                    [INT] => 0
                                                    [INTEGER] => 0
                                                    [MEDIUMINT] => 0
                                                    [SMALLINT] => 0
                                                    [TINYINT] => 0
                                                    [BIGINT] => 1
                                                    [SERIAL] => 1
                                                    [DEC] => 2
                                                    [DECIMAL] => 2
                                                    [DOUBLE] => 2
                                                    [DOUBLE PRECISION] => 2
                                                    [FIXED] => 2
                                                    [FLOAT] => 2
                                                )
                                            [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo
                                            [_config:protected] => Array
                                                (
                                                    [dbname] => psa
                                                    [host] => localhost
                                                    [port] => 3306
                                                    [username] => admin
                                                    [password] => $AES-128-CBC$PJaHyEyHEOwtXX9k/v/2Xg==$Q4cSQvW0jxXwDdY9XPYcXVvvpmwwply4qU/Iesu8vlg=
                                                    [charset] => utf8
                                                    [persistent] => 
                                                    [options] => Array
                                                        (
                                                            [caseFolding] => 0
                                                            [autoQuoteIdentifiers] => 1
                                                            [fetchMode] => 2
                                                        )
                                                    [driver_options] => Array
                                                        (
                                                        )
                                                )
                                            [_fetchMode:protected] => 2
                                            [_profiler:protected] => Zend_Db_Profiler Object
                                                (
                                                    [_queryProfiles:protected] => Array
                                                        (
                                                        )
                                                    [_enabled:protected] => 
                                                    [_filterElapsedSecs:protected] => 
                                                    [_filterTypes:protected] => 
                                                )
                                            [_defaultProfilerClass:protected] => Zend_Db_Profiler
                                            [_connection:protected] => PDO Object
                                                (
                                                )
                                            [_caseFolding:protected] => 0
                                            [_autoQuoteIdentifiers:protected] => 1
                                            [_allowSerialization:protected] => 1
                                            [_autoReconnectOnUnserialize:protected] => 
                                        )
                                    [_attribute:protected] => Array
                                        (
                                        )
                                    [_bindColumn:protected] => Array
                                        (
                                        )
                                    [_bindParam:protected] => Array
                                        (
                                        )
                                    [_sqlSplit:protected] => Array
                                        (
                                            [0] => select , , , , , , , , , , , , , , , , , , , , ,  from  where =1
                                        )
                                    [_sqlParam:protected] => Array
                                        (
                                            [0] => select , , , , , , , , , , , , , , , , , , , , ,  from  where =1
                                        )
                                    [_queryId:protected] => 
                                )
                            [error_] => 
                            [errorMsg_] => 
                        )
                    [needUpdate] => 
                    [idFieldName] => id
                    [existsInDb:cObject:private] => 1
                    [_onLoadValidationRules:protected] => Array
                        (
                        )
                    [error_] => 
                    [errorMsg_] => 
                )
        )
    [2] => pm_Domain Object
        (
            [_domainId:pm_Domain:private] => 2
            [_domain:pm_Domain:private] => Domain Object
                (
                    [dz:protected] => 
                    [_hasOwnDnsZoneBeforeUpdate:Domain:private] => 1
                    [domainUser:protected] => 
                    [_forceNew:protected] => 
                    [_webspace:Domain:private] => 
                    [oldTurnOffAction] => 
                    [attr] => Array
                        (
                            [id] => 2
                            [name] => alibaba.cloud
                            [displayName] => alibaba.cloud
                            [cr_date] => 2019-02-26
                            [status] => 0
                            [webspace_status] => 0
                            [dns_zone_id] => 2
                            [htype] => vrt_hst
                            [cl_id] => 2
                            [vendor_id] => 1
                            [webspace_id] => 1
                            [parentDomainId] => 0
                            [cert_rep_id] => 0
                            [real_size] => 0
                            [guid] => 803c8730-d508-486c-8354-26ec725377e6
                            [external_id] => 
                            [adminDescription] => 
                            [resellerDescription] => 
                            [description] => 
                            [overuse] => false
                            [icpStatus] => 0
                            [icpPermit] => 
                        )
                    [_changableAttr:cObject:private] => 
                    [oldAttr_] => Array
                        (
                            [id] => 2
                            [name] => alibaba.cloud
                            [displayName] => alibaba.cloud
                            [cr_date] => 2019-02-26
                            [status] => 0
                            [webspace_status] => 0
                            [dns_zone_id] => 2
                            [htype] => vrt_hst
                            [cl_id] => 2
                            [vendor_id] => 1
                            [webspace_id] => 1
                            [parentDomainId] => 0
                            [cert_rep_id] => 0
                            [real_size] => 0
                            [guid] => 803c8730-d508-486c-8354-26ec725377e6
                            [external_id] => 
                            [adminDescription] => 
                            [resellerDescription] => 
                            [description] => 
                            [overuse] => false
                            [icpStatus] => 0
                            [icpPermit] => 
                        )
                    [errorAttr] => Array
                        (
                        )
                    [reqAttr] => Array
                        (
                            [0] => id
                            [1] => name
                        )
                    [Table] => DomainTable Object
                        (
                            [tables] => Array
                                (
                                    [0] => domains
                                )
                            [fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                    [2] => displayName
                                    [3] => cr_date
                                    [4] => status
                                    [5] => webspace_status
                                    [6] => dns_zone_id
                                    [7] => htype
                                    [8] => cl_id
                                    [9] => vendor_id
                                    [10] => webspace_id
                                    [11] => parentDomainId
                                    [12] => cert_rep_id
                                    [13] => real_size
                                    [14] => guid
                                    [15] => external_id
                                    [16] => adminDescription
                                    [17] => resellerDescription
                                    [18] => description
                                    [19] => overuse
                                    [20] => icpStatus
                                    [21] => icpPermit
                                )
                            [primaryKeys:protected] => Array
                                (
                                    [id] => 2
                                )
                            [prefetchedRow:protected] => 
                            [id] => 2
                            [idAttrIndex] => 0
                            [where] => 
                            [order] => 
                            [result] => Zend_Db_Statement_Pdo Object
                                (
                                    [_fetchMode:protected] => 2
                                    [_stmt:protected] => PDOStatement Object
                                        (
                                            [queryString] => select `id`, `name`, `displayName`, `cr_date`, `status`, `webspace_status`, `dns_zone_id`, `htype`, `cl_id`, `vendor_id`, `webspace_id`, `parentDomainId`, `cert_rep_id`, `real_size`, `guid`, `external_id`, `adminDescription`, `resellerDescription`, `description`, `overuse`, `icpStatus`, `icpPermit` from `domains` where `id`=2
                                        )
                                    [_adapter:protected] => Db_Adapter_Pdo_Mysql Object
                                        (
                                            [_callbackCustomWarningNotification:protected] => 
                                            [_pdoType:protected] => mysql
                                            [_numericDataTypes:protected] => Array
                                                (
                                                    [0] => 0
                                                    [1] => 1
                                                    [2] => 2
                                                    [INT] => 0
                                                    [INTEGER] => 0
                                                    [MEDIUMINT] => 0
                                                    [SMALLINT] => 0
                                                    [TINYINT] => 0
                                                    [BIGINT] => 1
                                                    [SERIAL] => 1
                                                    [DEC] => 2
                                                    [DECIMAL] => 2
                                                    [DOUBLE] => 2
                                                    [DOUBLE PRECISION] => 2
                                                    [FIXED] => 2
                                                    [FLOAT] => 2
                                                )
                                            [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo
                                            [_config:protected] => Array
                                                (
                                                    [dbname] => psa
                                                    [host] => localhost
                                                    [port] => 3306
                                                    [username] => admin
                                                    [password] => $AES-128-CBC$PJaHyEyHEOwtXX9k/v/2Xg==$Q4cSQvW0jxXwDdY9XPYcXVvvpmwwply4qU/Iesu8vlg=
                                                    [charset] => utf8
                                                    [persistent] => 
                                                    [options] => Array
                                                        (
                                                            [caseFolding] => 0
                                                            [autoQuoteIdentifiers] => 1
                                                            [fetchMode] => 2
                                                        )
                                                    [driver_options] => Array
                                                        (
                                                        )
                                                )
                                            [_fetchMode:protected] => 2
                                            [_profiler:protected] => Zend_Db_Profiler Object
                                                (
                                                    [_queryProfiles:protected] => Array
                                                        (
                                                        )
                                                    [_enabled:protected] => 
                                                    [_filterElapsedSecs:protected] => 
                                                    [_filterTypes:protected] => 
                                                )
                                            [_defaultProfilerClass:protected] => Zend_Db_Profiler
                                            [_connection:protected] => PDO Object
                                                (
                                                )
                                            [_caseFolding:protected] => 0
                                            [_autoQuoteIdentifiers:protected] => 1
                                            [_allowSerialization:protected] => 1
                                            [_autoReconnectOnUnserialize:protected] => 
                                        )
                                    [_attribute:protected] => Array
                                        (
                                        )
                                    [_bindColumn:protected] => Array
                                        (
                                        )
                                    [_bindParam:protected] => Array
                                        (
                                        )
                                    [_sqlSplit:protected] => Array
                                        (
                                            [0] => select , , , , , , , , , , , , , , , , , , , , ,  from  where =2
                                        )
                                    [_sqlParam:protected] => Array
                                        (
                                            [0] => select , , , , , , , , , , , , , , , , , , , , ,  from  where =2
                                        )
                                    [_queryId:protected] => 
                                )
                            [error_] => 
                            [errorMsg_] => 
                        )
                    [needUpdate] => 
                    [idFieldName] => id
                    [existsInDb:cObject:private] => 1
                    [_onLoadValidationRules:protected] => Array
                        (
                        )
                    [error_] => 
                    [errorMsg_] => 
                )
        )
)

в этом коде два массива [1] и [2], в каждом из них есть параметр [name] => amazonaws.click с именем домена, так вот, мне нужно весь этот код прогнать через цикл и получить все имеющиеся домены, их может быть не два как в этом примере, а намного больше. Нужно каждый положить в массив отдельный.

Делаю вот так $json_encode = json_decode('МАССИВ ДАННЫХ',true); print $json_encode[1]; но ничего не выводит. Уже устал искать в поиске, прошу помощи :)

Answer 1

в массиве достаточно пройтись foreach...as вложенным на нужную глубину, а ключ и его значение можно искать по обычному условию IF.

READ ALSO
как правильно привернуть HBITMAP к make_unique вместе с deleter'ом

как правильно привернуть HBITMAP к make_unique вместе с deleter'ом

Как правильно привернуть HBITMAP к make_unique вместе с deleter'ом, под deleter'ом подразумевается вызов DeleteObject()

152
Почему нету вывода с функции Users.ShowList()? [закрыт]

Почему нету вывода с функции Users.ShowList()? [закрыт]

посмотрите внимательно на эти строки

135
Книги по OpenGL для начинающих [закрыт]

Книги по OpenGL для начинающих [закрыт]

Можете подсказать какие есть современные книги по OpenGl для начинающих и желательно на русском и по новее

143
построение Блок-схемы [закрыт]

построение Блок-схемы [закрыт]

ЗдраствуйтеНе подскажите какое либо пособие которые наглядно показывает как строить блок схемы для кодов C++ (а то я в этом вообще воробушек)

128