This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 7 years ago.
What's the most quickly way to deserialize a Json in PHP? Actual I thought not to use external libraries but to do everything through my code. I downloaded the resource:
$variable = file_get_contents("http://api.football-data.org/alpha/soccerseasons/");
$decoded = json_decode($variable);
var_dump($decoded);
Now I have everything in the variable array decoded, as you advise me to do to get all the values of the json?
UPDATE - DECODED CONTENT:
array(11) { [0]=> object(stdClass)#1 (7) { ["_links"]=> object(stdClass)#2 (4) { ["self"]=> object(stdClass)#3 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/394" } ["teams"]=> object(stdClass)#4 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/394/teams" } ["fixtures"]=> object(stdClass)#5 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/394/fixtures" } ["leagueTable"]=> object(stdClass)#6 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/394/leagueTable" } } ["caption"]=> string(21) "1. Bundesliga 2015/16" ["league"]=> string(3) "BL1" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(18) ["numberOfGames"]=> int(306) ["lastUpdated"]=> string(20) "2015-07-15T05:21:07Z" } [1]=> object(stdClass)#7 (7) { ["_links"]=> object(stdClass)#8 (4) { ["self"]=> object(stdClass)#9 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/395" } ["teams"]=> object(stdClass)#10 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/395/teams" } ["fixtures"]=> object(stdClass)#11 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/395/fixtures" } ["leagueTable"]=> object(stdClass)#12 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/395/leagueTable" } } ["caption"]=> string(21) "2. Bundesliga 2015/16" ["league"]=> string(3) "BL2" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(18) ["numberOfGames"]=> int(306) ["lastUpdated"]=> string(20) "2015-08-03T02:28:27Z" } [2]=> object(stdClass)#13 (7) { ["_links"]=> object(stdClass)#14 (4) { ["self"]=> object(stdClass)#15 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/396" } ["teams"]=> object(stdClass)#16 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/396/teams" } ["fixtures"]=> object(stdClass)#17 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/396/fixtures" } ["leagueTable"]=> object(stdClass)#18 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/396/leagueTable" } } ["caption"]=> string(15) "Ligue 1 2015/16" ["league"]=> string(3) "FL1" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(380) ["lastUpdated"]=> string(20) "2015-07-31T06:12:34Z" } [3]=> object(stdClass)#19 (7) { ["_links"]=> object(stdClass)#20 (4) { ["self"]=> object(stdClass)#21 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/397" } ["teams"]=> object(stdClass)#22 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/397/teams" } ["fixtures"]=> object(stdClass)#23 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/397/fixtures" } ["leagueTable"]=> object(stdClass)#24 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/397/leagueTable" } } ["caption"]=> string(15) "Ligue 2 2015/16" ["league"]=> string(3) "FL2" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(380) ["lastUpdated"]=> string(20) "2015-08-02T12:20:09Z" } [4]=> object(stdClass)#25 (7) { ["_links"]=> object(stdClass)#26 (4) { ["self"]=> object(stdClass)#27 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/398" } ["teams"]=> object(stdClass)#28 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/398/teams" } ["fixtures"]=> object(stdClass)#29 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/398/fixtures" } ["leagueTable"]=> object(stdClass)#30 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/398/leagueTable" } } ["caption"]=> string(22) "Premier League 2015/16" ["league"]=> string(2) "PL" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(380) ["lastUpdated"]=> string(20) "2015-07-31T06:02:18Z" } [5]=> object(stdClass)#31 (7) { ["_links"]=> object(stdClass)#32 (4) { ["self"]=> object(stdClass)#33 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/399" } ["teams"]=> object(stdClass)#34 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/399/teams" } ["fixtures"]=> object(stdClass)#35 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/399/fixtures" } ["leagueTable"]=> object(stdClass)#36 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/399/leagueTable" } } ["caption"]=> string(24) "Primera Division 2015/16" ["league"]=> string(2) "PD" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(380) ["lastUpdated"]=> string(20) "2015-07-15T05:27:20Z" } [6]=> object(stdClass)#37 (7) { ["_links"]=> object(stdClass)#38 (4) { ["self"]=> object(stdClass)#39 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/400" } ["teams"]=> object(stdClass)#40 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/400/teams" } ["fixtures"]=> object(stdClass)#41 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/400/fixtures" } ["leagueTable"]=> object(stdClass)#42 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/400/leagueTable" } } ["caption"]=> string(24) "Segunda Division 2015/16" ["league"]=> string(2) "SD" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(420) ["lastUpdated"]=> string(20) "2015-07-19T09:47:33Z" } [7]=> object(stdClass)#43 (7) { ["_links"]=> object(stdClass)#44 (4) { ["self"]=> object(stdClass)#45 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/401" } ["teams"]=> object(stdClass)#46 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/401/teams" } ["fixtures"]=> object(stdClass)#47 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/401/fixtures" } ["leagueTable"]=> object(stdClass)#48 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/401/leagueTable" } } ["caption"]=> string(15) "Serie A 2015/16" ["league"]=> string(2) "SA" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(380) ["lastUpdated"]=> string(20) "2015-07-31T06:00:43Z" } [8]=> object(stdClass)#49 (7) { ["_links"]=> object(stdClass)#50 (4) { ["self"]=> object(stdClass)#51 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/402" } ["teams"]=> object(stdClass)#52 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/402/teams" } ["fixtures"]=> object(stdClass)#53 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/402/fixtures" } ["leagueTable"]=> object(stdClass)#54 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/402/leagueTable" } } ["caption"]=> string(21) "Primeira Liga 2015/16" ["league"]=> string(3) "PPL" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(18) ["numberOfGames"]=> int(306) ["lastUpdated"]=> string(20) "2015-07-31T06:15:10Z" } [9]=> object(stdClass)#55 (7) { ["_links"]=> object(stdClass)#56 (4) { ["self"]=> object(stdClass)#57 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/403" } ["teams"]=> object(stdClass)#58 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/403/teams" } ["fixtures"]=> object(stdClass)#59 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/403/fixtures" } ["leagueTable"]=> object(stdClass)#60 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/403/leagueTable" } } ["caption"]=> string(21) "3. Bundesliga 2015/16" ["league"]=> string(3) "BL3" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(20) ["numberOfGames"]=> int(380) ["lastUpdated"]=> string(20) "2015-08-03T02:28:50Z" } [10]=> object(stdClass)#61 (7) { ["_links"]=> object(stdClass)#62 (4) { ["self"]=> object(stdClass)#63 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/404" } ["teams"]=> object(stdClass)#64 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/404/teams" } ["fixtures"]=> object(stdClass)#65 (1) { ["href"]=> string(61) "http://api.football-data.org/alpha/soccerseasons/404/fixtures" } ["leagueTable"]=> object(stdClass)#66 (1) { ["href"]=> string(64) "http://api.football-data.org/alpha/soccerseasons/404/leagueTable" } } ["caption"]=> string(18) "Eredivisie 2015/16" ["league"]=> string(3) "DED" ["year"]=> string(4) "2015" ["numberOfTeams"]=> int(18) ["numberOfGames"]=> int(306) ["lastUpdated"]=> string(20) "2015-08-03T02:34:21Z" } }
Try
$decoded = json_decode($variable,true);
it should create an array. Easier to use
Related
This question already has answers here:
How can I access an array/object?
(6 answers)
Closed 6 years ago.
How can I extract title and content from the array of JSON data that gives the following when I var_dump(WpApi::posts());
array(3) { ["results"]=> array(1)
{ [0]=> array(23)
{ ["id"]=> int(8)
["date"]=> string(19) "2017-01-31T07:08:21"
["date_gmt"]=> string(19) "2017-01-31T07:08:21"
["guid"]=> array(1) { ["rendered"]=> string(34) "http://idybrand.com/wordpress/?p=8" }
["modified"]=> string(19) "2017-01-31T07:08:21"
["modified_gmt"]=> string(19) "2017-01-31T07:08:21"
["slug"]=> string(34) "february-is-just-around-the-corner"
["type"]=> string(4) "post"
["link"]=> string(76) "http://idybrand.com/wordpress/2017/01/31/february-is-just-around-the-corner/"
["title"]=> array(1) { ["rendered"]=> string(34) "February is just around the corner" }
["content"]=> array(2) { ["rendered"]=> string(39) "
Appreciate this wonderful month
" ["protected"]=> bool(false) }
["excerpt"]=> array(2) { ["rendered"]=> string(39) "
Appreciate this wonderful month
" ["protected"]=> bool(false) }
["author"]=> int(1)
["featured_media"]=> int(0)
["comment_status"]=> string(4) "open"
["ping_status"]=> string(4) "open"
["sticky"]=> bool(false)
["template"]=> string(0) ""
["format"]=> string(8) "standard"
["meta"]=> array(0) { }
["categories"]=> array(1) { [0]=> int(1) }
["tags"]=> array(0) { }
["_links"]=> array(9) { ["self"]=> array(1) { [0]=> array(1) { ["href"]=> string(51) "http://idybrand.com/wordpress/wp-json/wp/v2/posts/8" } } ["collection"]=> array(1) { [0]=> array(1) { ["href"]=> string(49) "http://idybrand.com/wordpress/wp-json/wp/v2/posts" } } ["about"]=> array(1) { [0]=> array(1) { ["href"]=> string(54) "http://idybrand.com/wordpress/wp-json/wp/v2/types/post" } } ["author"]=> array(1) { [0]=> array(2) { ["embeddable"]=> bool(true) ["href"]=> string(51) "http://idybrand.com/wordpress/wp-json/wp/v2/users/1" } } ["replies"]=> array(1) { [0]=> array(2) { ["embeddable"]=> bool(true) ["href"]=> string(59) "http://idybrand.com/wordpress/wp-json/wp/v2/comments?post=8" } } ["version-history"]=> array(1) { [0]=> array(1) { ["href"]=> string(61) "http://idybrand.com/wordpress/wp-json/wp/v2/posts/8/revisions" } } ["wp:attachment"]=> array(1) { [0]=> array(1) { ["href"]=> string(58) "http://idybrand.com/wordpress/wp-json/wp/v2/media?parent=8" } } ["wp:term"]=> array(2) { [0]=> array(3) { ["taxonomy"]=> string(8) "category" ["embeddable"]=> bool(true) ["href"]=> string(61) "http://idybrand.com/wordpress/wp-json/wp/v2/categories?post=8" } [1]=> array(3) { ["taxonomy"]=> string(8) "post_tag" ["embeddable"]=> bool(true) ["href"]=> string(55) "http://idybrand.com/wordpress/wp-json/wp/v2/tags?post=8" } } ["curies"]=> array(1) { [0]=> array(3) { ["name"]=> string(2) "wp" ["href"]=> string(23) "https://api.w.org/{rel}" ["templated"]=> bool(true) } } } } }
["total"]=> string(1) "1"
["pages"]=> string(1) "1" }
Using PHP please
This will do it according to your JSON.
echo ['results'][0]['title']['rendered']; //Title
echo ['results'][0]['content']['rendered']; //Content
You've got a multi-dimensional array so you've to get data from it.
$arr = WpApi::posts();
$arr['results'][0]['content']['rendered'] //this is your content string
$arr['results'][0]['title']['rendered'] // this is your title string
After making the authentication in sabre from php and make an inquiry about a flight, the response is a JSON string that I can not decipher, someone aid me, as I can show this readable string in php for my project.
part of the code, thanks for your help
object(SharedContext)#3 (1) {
["results":"SharedContext":private]=>
array(7) {
["SECURITY"]=>``
NULL
["origin"]=>
string(3) "MTR"
["destination"]=>
string(3) "BOG"
["departureDate"]=>
string(10) "2016-06-10"
["LeadPriceCalendar"]=>
object(stdClass)#6 (5) {
["status"]=>
string(8) "Complete"
["type"]=>
string(11) "Application"
["errorCode"]=>
string(20) "WARN.RAF.APPLICATION"
["timeStamp"]=>
string(25) "2016-06-03T22:04:40+00:00"
["message"]=>
string(21) "No results were found"
}
["InstaFlight"]=>
NULL
["BargainFinderMax"]=>
object(stdClass)#4 (2) {
["OTA_AirLowFareSearchRS"]=>
object(stdClass)#10 (11) {
["PricedItinCount"]=>
int(6)
["BrandedOneWayItinCount"]=>
int(0)
["SimpleOneWayItinCount"]=>
int(0)
["DepartedItinCount"]=>
int(0)
["SoldOutItinCount"]=>
int(0)
["AvailableItinCount"]=>
int(0)
["Version"]=>
string(5) "1.8.6"
["Success"]=>
object(stdClass)#11 (0) {
}
["Warnings"]=>
object(stdClass)#12 (1) {
["Warning"]=>
array(4) {
[0]=>
object(stdClass)#13 (5) {
["Type"]=>
string(12) "WORKERTHREAD"
["ShortText"]=>
string(19) "1750772809123328107"
["Code"]=>
string(13) "TRANSACTIONID"
["MessageClass"]=>
string(1) "I"
["content"]=>
string(0) ""
}
[1]=>
object(stdClass)#14 (5) {
["Type"]=>
string(6) "SERVER"
["ShortText"]=>
string(5) "27037"
["Code"]=>
string(9) "TTFHLC702"
["MessageClass"]=>
string(1) "I"
["content"]=>
string(0) ""
}
[2]=>
object(stdClass)#15 (5) {
["Type"]=>
string(7) "DEFAULT"
["ShortText"]=>
string(5) "13330"
["Code"]=>
string(6) "RULEID"
["MessageClass"]=>
string(1) "I"
["content"]=>
string(0) ""
}
[3]=>
object(stdClass)#16 (5) {
["Type"]=>
string(3) "DRE"
["ShortText"]=>
string(5) "13291"
["Code"]=>
string(6) "RULEID"
["MessageClass"]=>
string(1) "I"
["content"]=>
string(0) ""
}
}
}
["PricedItineraries"]=>
object(stdClass)#17 (1) {
["PricedItinerary"]=>
array(6) {
[0]=>
object(stdClass)#18 (5) {
["SequenceNumber"]=>
int(1)
["AirItinerary"]=>
object(stdClass)#19 (2) {
["DirectionInd"]=>
string(6) "OneWay"
["OriginDestinationOptions"]=>
object(stdClass)#20 (1) {
["OriginDestinationOption"]=>
array(1) {
[0]=>
object(stdClass)#21 (2) {
["ElapsedTime"]=>
int(76)
["FlightSegment"]=>
array(1) {
[0]=>
object(stdClass)#22 (15) {
["DepartureDateTime"]=>
string(19) "2016-06-10T08:38:00"
["ArrivalDateTime"]=>
string(19) "2016-06-10T09:54:00"
["StopQuantity"]=>
int(0)
["FlightNumber"]=>
string(4) "3193"
["ResBookDesigCode"]=>
string(1) "Q"
["ElapsedTime"]=>
int(76)
["DepartureAirport"]=>
object(stdClass)#23 (2) {
["LocationCode"]=>
string(3) "MTR"
["content"]=>
string(0) ""
}
["ArrivalAirport"]=>
object(stdClass)#24 (3) {
["LocationCode"]=>
string(3) "BOG"
["TerminalID"]=>
string(1) "1"
["content"]=>
string(0) ""
}
["OperatingAirline"]=>
object(stdClass)#25 (4) {
["CompanyShortName"]=>
string(26) "LAN COLOMBIA AIRLINES S.A."
["Code"]=>
string(2) "LA"
["FlightNumber"]=>
string(4) "3193"
["content"]=>
string(0) ""
}
["Equipment"]=>
array(1) {
[0]=>
object(stdClass)#26 (2) {
["AirEquipType"]=>
string(3) "320"
["content"]=>
string(0) ""
}
}
["MarketingAirline"]=>
object(stdClass)#27 (2) {
["Code"]=>
string(2) "LA"
["content"]=>
string(0) ""
}
["MarriageGrp"]=>
string(1) "O"
["DepartureTimeZone"]=>
object(stdClass)#28 (1) {
["GMTOffset"]=>
float(-5)
}
["ArrivalTimeZone"]=>
object(stdClass)#29 (1) {
["GMTOffset"]=>
float(-5)
}
["TPA_Extensions"]=>
object(stdClass)#30 (1) {
["eTicket"]=>
object(stdClass)#31 (1) {
["Ind"]=>
bool(true)
}
}
}
}
}
}
}
}
I'm trying to get my head around the Paypal PHP REST SDK response from the Payment API,
var_dump of json_decode of the response is NULL.
I've also tried changing the format to UTF_8 with utf8_encode($response) but still getting null.
var_dump($response) is per below
object(PayPal\Api\Payment)#8 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(8) {
["id"]=>
string(28) "PAY-8JC052XXXXKKZMQNQ"
["create_time"]=>
string(20) "2013-12-19T10:19:34Z"
["update_time"]=>
string(20) "2013-12-19T10:20:38Z"
["state"]=>
string(8) "approved"
["intent"]=>
string(4) "sale"
["payer"]=>
object(PayPal\Api\Payer)#33 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(2) {
["payment_method"]=>
string(6) "paypal"
["payer_info"]=>
object(PayPal\Api\PayerInfo)#30 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(5) {
["email"]=>
string(11) "some#email.com"
["first_name"]=>
string(6) "fname"
["last_name"]=>
string(5) "lname"
["payer_id"]=>
string(13) "UAGGF3392CUTG"
["shipping_address"]=>
object(PayPal\Api\Address)#31 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(5) {
["line1"]=>
string(26) "Address"
["city"]=>
string(13) "City"
["state"]=>
string(8) "State"
["postal_code"]=>
string(5) "000000"
["country_code"]=>
string(2) "US"
}
}
}
}
}
}
["transactions"]=>
array(1) {
[0]=>
object(PayPal\Api\Transaction)#34 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(4) {
["amount"]=>
object(PayPal\Api\Amount)#35 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(3) {
["total"]=>
string(4) "1.00"
["currency"]=>
string(3) "USD"
["details"]=>
object(PayPal\Api\Details)#36 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(1) {
["subtotal"]=>
string(4) "1.00"
}
}
}
}
["description"]=>
string(33) "Item name: 1"
["item_list"]=>
object(PayPal\Api\ItemList)#37 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(1) {
["items"]=>
array(1) {
[0]=>
object(PayPal\Api\Item)#38 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(4) {
["name"]=>
string(20) "Item name"
["price"]=>
string(4) "1.00"
["currency"]=>
string(3) "USD"
["quantity"]=>
string(1) "1"
}
}
}
}
}
["related_resources"]=>
array(1) {
[0]=>
object(PayPal\Api\RelatedResources)#40 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(1) {
["sale"]=>
object(PayPal\Api\Sale)#42 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(7) {
["id"]=>
string(17) "5DH04XXX63X"
["create_time"]=>
string(20) "2013-12-19T10:19:34Z"
["update_time"]=>
string(20) "2013-12-19T10:20:38Z"
["state"]=>
string(9) "completed"
["amount"]=>
object(PayPal\Api\Amount)#44 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(2) {
["total"]=>
string(4) "1.00"
["currency"]=>
string(3) "USD"
}
}
["parent_payment"]=>
string(28) "PAY-8JC05XXXXKZMQNQ"
["links"]=>
array(3) {
[0]=>
object(PayPal\Api\Links)#46 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(3) {
["href"]=>
string(65) "https://api.sandbox.paypal.com/v1/payments/sale/5DHXX91763X"
["rel"]=>
string(4) "self"
["method"]=>
string(3) "GET"
}
}
[1]=>
object(PayPal\Api\Links)#47 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(3) {
["href"]=>
string(72) "https://api.sandbox.paypal.com/v1/payments/sale/5DHXXA691763X/refund"
["rel"]=>
string(6) "refund"
["method"]=>
string(4) "POST"
}
}
[2]=>
object(PayPal\Api\Links)#48 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(3) {
["href"]=>
string(79) "https://api.sandbox.paypal.com/v1/payments/payment/PAY-8JC052914XX1034SKKZMQNQ"
["rel"]=>
string(14) "parent_payment"
["method"]=>
string(3) "GET"
}
}
}
}
}
}
}
}
}
}
}
["links"]=>
array(1) {
[0]=>
object(PayPal\Api\Links)#49 (1) {
["_propMap":"PayPal\Common\PPModel":private]=>
array(3) {
["href"]=>
string(79) "https://api.sandbox.paypal.com/v1/payments/payment/PAY-8JC0XX914D601034SKKZMQNQ"
["rel"]=>
string(4) "self"
["method"]=>
string(3) "GET"
}
}
}
}
}
I am using Twitter Search API and it returs an array of objects. I have to check for each object if it contains ['media'] array. Below is one of the objects with media attribute.
object(stdClass)#56 (4) {
["hashtags"]=>
array(2) {
[0]=>
object(stdClass)#57 (2) {
["text"]=>
string(9) "katyperry"
["indices"]=>
array(2) {
[0]=>
int(62)
[1]=>
int(72)
}
}
[1]=>
object(stdClass)#58 (2) {
["text"]=>
string(8) "katycats"
["indices"]=>
array(2) {
[0]=>
int(73)
[1]=>
int(82)
}
}
}
["urls"]=>
array(0) {
}
["user_mentions"]=>
array(1) {
[0]=>
object(stdClass)#59 (5) {
["screen_name"]=>
string(13) "perfkatyperry"
["name"]=>
string(7) "KatyCat"
["id"]=>
int(611836599)
["id_str"]=>
string(9) "611836599"
["indices"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(17)
}
}
}
["media"]=>
array(1) {
[0]=>
object(stdClass)#60 (10) {
["id"]=>
int(325747221490434048)
["id_str"]=>
string(18) "325747221490434048"
["indices"]=>
array(2) {
[0]=>
int(83)
[1]=>
int(105)
}
["media_url"]=>
string(46) "http://pbs.twimg.com/media/BIVJXz-CAAAHQ8M.jpg"
["media_url_https"]=>
string(47) "https://pbs.twimg.com/media/BIVJXz-CAAAHQ8M.jpg"
["url"]=>
string(22) "http://t.co/RYgQ8Srze5"
["display_url"]=>
string(26) "pic.twitter.com/RYgQ8Srze5"
["expanded_url"]=>
string(66) "http://twitter.com/perfkatyperry/status/325747221486239744/photo/1"
["type"]=>
string(5) "photo"
["sizes"]=>
object(stdClass)#61 (5) {
["medium"]=>
object(stdClass)#62 (3) {
["w"]=>
int(600)
["h"]=>
int(600)
["resize"]=>
string(3) "fit"
}
["thumb"]=>
object(stdClass)#63 (3) {
["w"]=>
int(150)
["h"]=>
int(150)
["resize"]=>
string(4) "crop"
}
["large"]=>
object(stdClass)#64 (3) {
["w"]=>
int(1024)
["h"]=>
int(1024)
["resize"]=>
string(3) "fit"
}
["small"]=>
object(stdClass)#65 (3) {
["w"]=>
int(340)
["h"]=>
int(340)
["resize"]=>
string(3) "fit"
}
["orig"]=>
object(stdClass)#66 (3) {
["w"]=>
int(1024)
["h"]=>
int(1024)
["resize"]=>
string(3) "fit"
}
}
}
}
}
How can i do that?
Thanks!
Use a loop + property_exists function:
foreach($myArray as $obj)
{
if(!property_exists($obj, 'media') || !is_array($obj->media))
{
echo("property 'media' does not exist in $obj");
// throw exception, fill in default value for media array, set variable, whatever.
}
}
How would I parse the following to get the description, title , item number etc...of a product retrieved from Amazon's Product Advertising API?
I've used the following but it's not consistent.
$response = $client->responseGroup('Small,Images')->category('Books')->search($search);
foreach ($response->Items->Request->Item as $message) {
echo $message->Description;
}
Output below: also found on pastebin. The code below is the output. I want to select the title, description and url data from the object and nothing else preferably in array format.
Any ideas?
object(stdClass)#6 (2) {
["OperationRequest"]=>
object(stdClass)#7 (4) {
["HTTPHeaders"]=>
object(stdClass)#8 (1) {
["Header"]=>
object(stdClass)#9 (2) {
["Name"]=>
string(9) "UserAgent"
["Value"]=>
string(26) "PHP-SOAP/5.3.2-1ubuntu4.18"
}
}
["RequestId"]=>
string(36) "cbcaa978-487c-4d83-8986-6a641b7d9c00"
["Arguments"]=>
object(stdClass)#10 (1) {
["Argument"]=>
object(stdClass)#11 (2) {
["Name"]=>
string(7) "Service"
["Value"]=>
string(19) "AWSECommerceService"
}
}
["RequestProcessingTime"]=>
float(0.081366)
}
["Items"]=>
object(stdClass)#12 (5) {
["Request"]=>
object(stdClass)#13 (2) {
["IsValid"]=>
string(4) "True"
["ItemSearchRequest"]=>
object(stdClass)#14 (3) {
["Keywords"]=>
string(9) "airplanes"
["ResponseGroup"]=>
array(2) {
[0]=>
string(5) "Small"
[1]=>
string(6) "Images"
}
["SearchIndex"]=>
string(5) "Books"
}
}
["TotalResults"]=>
int(21343)
["TotalPages"]=>
int(2135)
["MoreSearchResultsUrl"]=>
string(237) "http://www.amazon.com/gp/redirect.html?camp=2025&creative=386001&location=http%3A%2F%2Fwww.amazon.com%2Fgp%2Fsearch%3Fkeywords%3Dairplanes%26url%3Dsearch-alias%253Dstripbooks&linkCode=sp1&tag=xxxxxxxxxxxxxxbet-20&SubscriptionId=AKIAII3UF3HPAPY3SMDQ"
["Item"]=>
array(10) {
[0]=>
object(stdClass)#15 (8) {
["ASIN"]=>
string(10) "0789465213"
["DetailPageURL"]=>
string(205) "http://www.amazon.com/Big-Book-Airplanes-DK-Publishing/dp/0789465213%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0789465213"
["ItemLinks"]=>
object(stdClass)#16 (1) {
["ItemLink"]=>
array(7) {
[0]=>
object(stdClass)#17 (2) {
["Description"]=>
string(17) "Technical Details"
["URL"]=>
string(215) "http://www.amazon.com/Big-Book-Airplanes-DK-Publishing/dp/tech-data/0789465213%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
[1]=>
object(stdClass)#18 (2) {
["Description"]=>
string(20) "Add To Baby Registry"
["URL"]=>
string(211) "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0789465213%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
[2]=>
object(stdClass)#19 (2) {
["Description"]=>
string(23) "Add To Wedding Registry"
["URL"]=>
string(214) "http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0789465213%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
[3]=>
object(stdClass)#20 (2) {
["Description"]=>
string(15) "Add To Wishlist"
["URL"]=>
string(215) "http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0789465213%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
[4]=>
object(stdClass)#21 (2) {
["Description"]=>
string(13) "Tell A Friend"
["URL"]=>
string(180) "http://www.amazon.com/gp/pdp/taf/0789465213%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
[5]=>
object(stdClass)#22 (2) {
["Description"]=>
string(20) "All Customer Reviews"
["URL"]=>
string(184) "http://www.amazon.com/review/product/0789465213%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
[6]=>
object(stdClass)#23 (2) {
["Description"]=>
string(10) "All Offers"
["URL"]=>
string(186) "http://www.amazon.com/gp/offer-listing/0789465213%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0789465213"
}
}
}
["SmallImage"]=>
object(stdClass)#24 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL75_.jpg"
["Height"]=>
object(stdClass)#25 (2) {
["_"]=>
string(2) "75"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#26 (2) {
["_"]=>
string(2) "56"
["Units"]=>
string(6) "pixels"
}
}
["MediumImage"]=>
object(stdClass)#27 (3) {
["URL"]=>
string(61) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL160_.jpg"
["Height"]=>
object(stdClass)#28 (2) {
["_"]=>
string(3) "160"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#29 (2) {
["_"]=>
string(3) "120"
["Units"]=>
string(6) "pixels"
}
}
["LargeImage"]=>
object(stdClass)#30 (3) {
["URL"]=>
string(53) "http://ecx.images-amazon.com/images/I/51G392LNnWL.jpg"
["Height"]=>
object(stdClass)#31 (2) {
["_"]=>
string(3) "500"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#32 (2) {
["_"]=>
string(3) "376"
["Units"]=>
string(6) "pixels"
}
}
["ImageSets"]=>
object(stdClass)#33 (1) {
["ImageSet"]=>
object(stdClass)#34 (7) {
["SwatchImage"]=>
object(stdClass)#35 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL30_.jpg"
["Height"]=>
object(stdClass)#36 (2) {
["_"]=>
string(2) "30"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#37 (2) {
["_"]=>
string(2) "23"
["Units"]=>
string(6) "pixels"
}
}
["SmallImage"]=>
object(stdClass)#38 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL75_.jpg"
["Height"]=>
object(stdClass)#39 (2) {
["_"]=>
string(2) "75"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#40 (2) {
["_"]=>
string(2) "56"
["Units"]=>
string(6) "pixels"
}
}
["ThumbnailImage"]=>
object(stdClass)#41 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL75_.jpg"
["Height"]=>
object(stdClass)#42 (2) {
["_"]=>
string(2) "75"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#43 (2) {
["_"]=>
string(2) "56"
["Units"]=>
string(6) "pixels"
}
}
["TinyImage"]=>
object(stdClass)#44 (3) {
["URL"]=>
string(61) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL110_.jpg"
["Height"]=>
object(stdClass)#45 (2) {
["_"]=>
string(3) "110"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#46 (2) {
["_"]=>
string(2) "83"
["Units"]=>
string(6) "pixels"
}
}
["MediumImage"]=>
object(stdClass)#47 (3) {
["URL"]=>
string(61) "http://ecx.images-amazon.com/images/I/51G392LNnWL._SL160_.jpg"
["Height"]=>
object(stdClass)#48 (2) {
["_"]=>
string(3) "160"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#49 (2) {
["_"]=>
string(3) "120"
["Units"]=>
string(6) "pixels"
}
}
["LargeImage"]=>
object(stdClass)#50 (3) {
["URL"]=>
string(53) "http://ecx.images-amazon.com/images/I/51G392LNnWL.jpg"
["Height"]=>
object(stdClass)#51 (2) {
["_"]=>
string(3) "500"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#52 (2) {
["_"]=>
string(3) "376"
["Units"]=>
string(6) "pixels"
}
}
["Category"]=>
string(7) "primary"
}
}
["ItemAttributes"]=>
object(stdClass)#53 (4) {
["Author"]=>
string(13) "DK Publishing"
["Manufacturer"]=>
string(11) "DK CHILDREN"
["ProductGroup"]=>
string(4) "Book"
["Title"]=>
string(21) "Big Book of Airplanes"
}
}
[1]=>
object(stdClass)#54 (8) {
["ASIN"]=>
string(10) "0753459159"
["DetailPageURL"]=>
string(211) "http://www.amazon.com/Amazing-Airplanes-Machines-Tony-Mitton/dp/0753459159%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0753459159"
["ItemLinks"]=>
object(stdClass)#55 (1) {
["ItemLink"]=>
array(7) {
[0]=>
object(stdClass)#56 (2) {
["Description"]=>
string(17) "Technical Details"
["URL"]=>
string(221) "http://www.amazon.com/Amazing-Airplanes-Machines-Tony-Mitton/dp/tech-data/0753459159%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
[1]=>
object(stdClass)#57 (2) {
["Description"]=>
string(20) "Add To Baby Registry"
["URL"]=>
string(211) "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0753459159%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
[2]=>
object(stdClass)#58 (2) {
["Description"]=>
string(23) "Add To Wedding Registry"
["URL"]=>
string(214) "http://www.amazon.com/gp/registry/wedding/add-item.html%3Fasin.0%3D0753459159%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
[3]=>
object(stdClass)#59 (2) {
["Description"]=>
string(15) "Add To Wishlist"
["URL"]=>
string(215) "http://www.amazon.com/gp/registry/wishlist/add-item.html%3Fasin.0%3D0753459159%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
[4]=>
object(stdClass)#60 (2) {
["Description"]=>
string(13) "Tell A Friend"
["URL"]=>
string(180) "http://www.amazon.com/gp/pdp/taf/0753459159%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
[5]=>
object(stdClass)#61 (2) {
["Description"]=>
string(20) "All Customer Reviews"
["URL"]=>
string(184) "http://www.amazon.com/review/product/0753459159%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
[6]=>
object(stdClass)#62 (2) {
["Description"]=>
string(10) "All Offers"
["URL"]=>
string(186) "http://www.amazon.com/gp/offer-listing/0753459159%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0753459159"
}
}
}
["SmallImage"]=>
object(stdClass)#63 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL75_.jpg"
["Height"]=>
object(stdClass)#64 (2) {
["_"]=>
string(2) "75"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#65 (2) {
["_"]=>
string(2) "74"
["Units"]=>
string(6) "pixels"
}
}
["MediumImage"]=>
object(stdClass)#66 (3) {
["URL"]=>
string(61) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL160_.jpg"
["Height"]=>
object(stdClass)#67 (2) {
["_"]=>
string(3) "160"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#68 (2) {
["_"]=>
string(3) "157"
["Units"]=>
string(6) "pixels"
}
}
["LargeImage"]=>
object(stdClass)#69 (3) {
["URL"]=>
string(53) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL.jpg"
["Height"]=>
object(stdClass)#70 (2) {
["_"]=>
string(3) "500"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#71 (2) {
["_"]=>
string(3) "491"
["Units"]=>
string(6) "pixels"
}
}
["ImageSets"]=>
object(stdClass)#72 (1) {
["ImageSet"]=>
object(stdClass)#73 (7) {
["SwatchImage"]=>
object(stdClass)#74 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL30_.jpg"
["Height"]=>
object(stdClass)#75 (2) {
["_"]=>
string(2) "30"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#76 (2) {
["_"]=>
string(2) "29"
["Units"]=>
string(6) "pixels"
}
}
["SmallImage"]=>
object(stdClass)#77 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL75_.jpg"
["Height"]=>
object(stdClass)#78 (2) {
["_"]=>
string(2) "75"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#79 (2) {
["_"]=>
string(2) "74"
["Units"]=>
string(6) "pixels"
}
}
["ThumbnailImage"]=>
object(stdClass)#80 (3) {
["URL"]=>
string(60) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL75_.jpg"
["Height"]=>
object(stdClass)#81 (2) {
["_"]=>
string(2) "75"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#82 (2) {
["_"]=>
string(2) "74"
["Units"]=>
string(6) "pixels"
}
}
["TinyImage"]=>
object(stdClass)#83 (3) {
["URL"]=>
string(61) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL110_.jpg"
["Height"]=>
object(stdClass)#84 (2) {
["_"]=>
string(3) "110"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#85 (2) {
["_"]=>
string(3) "108"
["Units"]=>
string(6) "pixels"
}
}
["MediumImage"]=>
object(stdClass)#86 (3) {
["URL"]=>
string(61) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL._SL160_.jpg"
["Height"]=>
object(stdClass)#87 (2) {
["_"]=>
string(3) "160"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#88 (2) {
["_"]=>
string(3) "157"
["Units"]=>
string(6) "pixels"
}
}
["LargeImage"]=>
object(stdClass)#89 (3) {
["URL"]=>
string(53) "http://ecx.images-amazon.com/images/I/51VcEPd9jqL.jpg"
["Height"]=>
object(stdClass)#90 (2) {
["_"]=>
string(3) "500"
["Units"]=>
string(6) "pixels"
}
["Width"]=>
object(stdClass)#91 (2) {
["_"]=>
string(3) "491"
["Units"]=>
string(6) "pixels"
}
}
["Category"]=>
string(7) "primary"
}
}
["ItemAttributes"]=>
object(stdClass)#92 (4) {
["Author"]=>
array(2) {
[0]=>
string(11) "Tony Mitton"
[1]=>
string(10) "Ant Parker"
}
["Manufacturer"]=>
string(10) "Kingfisher"
["ProductGroup"]=>
string(4) "Book"
["Title"]=>
string(36) "Amazing Airplanes (Amazing Machines)"
}
}
[2]=>
object(stdClass)#93 (8) {
["ASIN"]=>
string(10) "0061143812"
["DetailPageURL"]=>
string(214) "http://www.amazon.com/In-Cockpit-Inside-History-Making-Aircraft/dp/0061143812%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0061143812"
["ItemLinks"]=>
object(stdClass)#94 (1) {
["ItemLink"]=>
array(7) {
[0]=>
object(stdClass)#95 (2) {
["Description"]=>
string(17) "Technical Details"
["URL"]=>
string(224) "http://www.amazon.com/In-Cockpit-Inside-History-Making-Aircraft/dp/tech-data/0061143812%3FSubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0061143812"
}
[1]=>
object(stdClass)#96 (2) {
["Description"]=>
string(20) "Add To Baby Registry"
["URL"]=>
string(211) "http://www.amazon.com/gp/registry/baby/add-item.html%3Fasin.0%3D0061143812%26SubscriptionId%3DAKIAII3UF3HPAPY3SMDQ%26tag%3Dxxxxxxxxxxxxxxbet-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D386001%26creativeASIN%3D0061143812"
etc....
first of all you can print response array to view in array format then get element which you want, example below :)
echo '<pre>';
print_r($response);
echo '</pre>';
foreach($response['Items']['Item'] as $item)
{
echo 'asin :'.$item[ASIN].'<br>';
echo 'Title :'.$item[ItemAttributes][Title].'<br>';
echo '<image src="'.$item[MediumImage][URL].'">';
}