У меня есть php переменная $response
, содержащая объект с защищенными ключами:
FindCompletedItemsResponse Object (
[searchResult:protected] => SearchResult Object (
[item:protected] => Array (
[0] => SearchItem Object (
[itemId:protected] => 383198481839
[title:protected] => Matchbox SCX SRS2 Jaguar "XJR-14" Super Racing Castrol #4 Slot Car 1/32 NIB
[globalId:protected] => EBAY-US
[primaryCategory:protected] => Category Object (
[categoryId:protected] => 4781
[categoryName:protected] => 1970-Now
)
[galleryURL:protected] => https://thumbs4.ebaystatic.com/m/mslyccjMA3BvwuDua4N-kkg/140.jpg
[viewItemURL:protected] => https://www.ebay.com/itm/Matchbox-SCX-SRS2-Jaguar-XJR-14-Super-Racing-Castrol-4-Slot-Car-1-32-NIB-/383198481839
[paymentMethod:protected] => Array ( [0] => PayPal )
[postalCode:protected] => 923**
[location:protected] => Fontana,CA,USA
[country:protected] => US
[shippingInfo:protected] => ShippingInfo Object (
[shippingServiceCost:protected] => Amount Object (
[attributeValues] => Array (
[currencyId] => USD
)
[value:protected] => 8.95
)
[shippingType:protected] => Flat
[shipToLocations:protected] => Array (
[0] => Worldwide
)
[expeditedShipping:protected] => 1
[handlingTime:protected] => 1
)
[sellingStatus:protected] => SellingStatus Object (
[currentPrice:protected] => Amount Object (
[attributeValues] => Array (
[currencyId] => USD
)
[value:protected] => 49.95
)
[convertedCurrentPrice:protected] => Amount Object (
[attributeValues] => Array (
[currencyId] => USD
)
[value:protected] => 49.95
)
[sellingState:protected] => EndedWithSales
)
[listingInfo:protected] => ListingInfo Object (
[startTime:protected] => 2019-10-07T18:28:15.000Z
[endTime:protected] => 2020-01-15T22:19:56.000Z
[listingType:protected] => StoreInventory
)
[returnsAccepted:protected] => 1
[condition:protected] => Condition Object (
[conditionId:protected] => 1000
[conditionDisplayName:protected] => New
)
)
)
[attributeValues] => Array (
[count] => 1
)
)
[paginationOutput:protected] => PaginationOutput Object (
[pageNumber:protected] => 1
[entriesPerPage:protected] => 100
[totalPages:protected] => 1
[totalEntries:protected] => 1
)
[ack:protected] => Success
[version:protected] => 1.13.0
[timestamp:protected] => 2020-04-09T10:01:15.148Z
)
Я хотел бы преобразовать это в обычный многомерный массив php, где я могу получить доступ, например, к заголовку как $response[0]["title"]
.
Я пытался get_object_vars($response)
и json_decode(json_encode($response), true)
, но это ничего не делает, когда я смотрю на распечатанные результаты.
, и я попробовал эту функцию:
function o2a($obj) {
if(!is_array($obj) && !is_object($obj)) return $obj;
if(is_object($obj)) $obj = get_object_vars($obj);
return array_map(__FUNCTION__, $obj);
}
но он просто дает пустой массив: (.
Заранее благодарю за помощь.