PHP std::Class check if attribute exists - php

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.
}
}

Related

SimpleXml array to string PHP

My PHP function is returning a SimpleXML array like this:
array(1) { [0]=> object(SimpleXMLElement)#6 (18) { ["#attributes"]=> array(6) { ["thumbnailUrl"]=> string(47) "users/908/721/swagg_ma_blue/thumbnail-12612.jpg" ["default"]=> string(1) "1" ["name"]=> string(5) "_copy" ["color"]=> string(8) "0xBB9977" ["mood"]=> string(1) "3" ["species"]=> string(4) "stud" } ["head"]=> object(SimpleXMLElement)#5 (1) { ["#attributes"]=> array(4) { ["url"]=> string(51) "http://assets.zwinky.com/assets/stud/heads/01/head1" ["c"]=> string(8) "0xF2B38A" ["c2"]=> string(8) "0xffffff" ["z"]=> string(5) "33000" } } ["face"]=> object(SimpleXMLElement)#7 (1) { ["#attributes"]=> array(5) { ["url"]=> string(51) "http://assets.zwinky.com/assets/stud/faces/01/stud1" ["c"]=> string(8) "0xFFFFFF" ["displayName"]=> string(5) "stud1" ["z"]=> string(5) "34000" ["id"]=> string(8) "20017217" } } ["belt"]=> array(2) { [0]=> object(SimpleXMLElement)#8 (1) { ["#attributes"]=> array(6) { ["url"]=> string(64) "http://assets.zwinky.com/assets/store/zwinky/stud/belts/01/Vblt1" ["c"]=> string(8) "0x000000" ["c2"]=> string(8) "0xFFFFFF" ["displayName"]=> string(30) "Tough Love Belt ketamine-dolly" ["z"]=> string(5) "20100" ["id"]=> string(8) "20098984" } } [1]=> object(SimpleXMLElement)#20 (1) { ["#attributes"]=> array(5) { ["url"]=> string(76) "http://ak.ugc.zwinky.com/zwinky/fds/creations/791/402/z-justin/1441479408229" ["isUgc"]=> string(4) "true" ["displayName"]=> string(9) "My Design" ["z"]=> string(5) "20100" ["id"]=> string(8) "20081015" } } } ["midsection"]=> object(SimpleXMLElement)#9 (1) { ["#attributes"]=> array(2) { ["url"]=> string(55) "http://assets.zwinky.com/assets/stud/midsections/01/ms1" ["z"]=> string(4) "9000" } } ["leg"]=> object(SimpleXMLElement)#10 (1) { ["#attributes"]=> array(2) { ["url"]=> string(50) "http://assets.zwinky.com/assets/stud/legs/01/legs1" ["z"]=> string(5) "10000" } } ["hair"]=> object(SimpleXMLElement)#11 (1) { ["#attributes"]=> array(6) { ["url"]=> string(62) "http://assets.zwinky.com/assets/store/zwinky/stud/hair/01/Zhr8" ["c"]=> string(8) "0xD0C0B0" ["c2"]=> string(8) "0x000000" ["displayName"]=> string(7) "spiky 3" ["z"]=> string(5) "37000" ["id"]=> string(8) "20013196" } } ["shirt"]=> object(SimpleXMLElement)#12 (1) { ["#attributes"]=> array(5) { ["url"]=> string(63) "http://assets.zwinky.com/assets/store/zwinky/stud/tops/01/Vtop2" ["c"]=> string(8) "0x212121" ["displayName"]=> string(8) "tank top" ["z"]=> string(5) "21000" ["id"]=> string(8) "20012196" } } ["jacket"]=> object(SimpleXMLElement)#13 (1) { ["#attributes"]=> array(5) { ["url"]=> string(76) "http://ak.ugc.zwinky.com/zwinky/fds/creations/113/681/b4d_b0yy/1452451820582" ["isUgc"]=> string(4) "true" ["displayName"]=> string(4) "asdf" ["z"]=> string(5) "30000" ["id"]=> string(8) "20080934" } } ["bottom"]=> object(SimpleXMLElement)#14 (1) { ["#attributes"]=> array(6) { ["url"]=> string(67) "http://assets.zwinky.com/assets/store/zwinky/stud/bottoms/01/MXbm14" ["c"]=> string(8) "0xD6D6D6" ["c2"]=> string(8) "0xFFFFFF" ["displayName"]=> string(15) "Steampunk Pants" ["z"]=> string(5) "20000" ["id"]=> string(8) "20039549" } } ["electronic"]=> object(SimpleXMLElement)#15 (1) { ["#attributes"]=> array(5) { ["url"]=> string(64) "http://assets.zwinky.com/assets/store/zwinky/stud/misc/01/SDmis1" ["c"]=> string(8) "0x3366FF" ["displayName"]=> string(12) "game player2" ["z"]=> string(5) "45000" ["id"]=> string(8) "20017518" } } ["hat"]=> object(SimpleXMLElement)#16 (1) { ["#attributes"]=> array(5) { ["url"]=> string(49) "http://assets.zwinky.com/assets/stud/hats/01/hat6" ["c"]=> string(3) "0x0" ["displayName"]=> string(13) "baseball cap2" ["z"]=> string(5) "40000" ["id"]=> string(8) "20017403" } } ["earrings"]=> object(SimpleXMLElement)#17 (1) { ["#attributes"]=> array(4) { ["url"]=> string(52) "http://assets.zwinky.com/assets/stud/earrings/01/er2" ["displayName"]=> string(10) "gold hoops" ["z"]=> string(5) "39000" ["id"]=> string(8) "20017442" } } ["bracelet"]=> object(SimpleXMLElement)#18 (1) { ["#attributes"]=> array(6) { ["url"]=> string(67) "http://assets.zwinky.com/assets/store/zwinky/stud/bracelets/01/Zbr1" ["c"]=> string(8) "0xFFFFFF" ["c2"]=> string(8) "0xB5B5B5" ["displayName"]=> string(13) "Leather Cuffs" ["z"]=> string(5) "13000" ["id"]=> string(8) "20013217" } } ["necklace"]=> object(SimpleXMLElement)#19 (1) { ["#attributes"]=> array(5) { ["url"]=> string(68) "http://assets.zwinky.com/assets/store/zwinky/stud/necklaces/01/SDnk1" ["c"]=> string(8) "0xffffff" ["displayName"]=> string(14) "Snoop Necklace" ["z"]=> string(5) "23000" ["id"]=> string(8) "20012554" } } ["facialhair"]=> object(SimpleXMLElement)#21 (1) { ["#attributes"]=> array(5) { ["url"]=> string(69) "http://assets.zwinky.com/assets/store/zwinky/stud/facialhair/01/Vfhr1" ["c"]=> string(8) "0xffffff" ["displayName"]=> string(16) "Evil Cupid beard" ["z"]=> string(5) "38000" ["id"]=> string(8) "20012194" } } ["food"]=> object(SimpleXMLElement)#22 (1) { ["#attributes"]=> array(4) { ["url"]=> string(64) "http://assets.zwinky.com/assets/store/zwinky/stud/misc/01/HWmis7" ["displayName"]=> string(11) "mug w/steam" ["z"]=> string(5) "47000" ["id"]=> string(8) "20017604" } } ["facialdecorations"]=> object(SimpleXMLElement)#23 (1) { ["#attributes"]=> array(5) { ["url"]=> string(88) "http://ak.ugc.zwinky.com/zwinky/fds/creations/235/447/simsea-gdh0thtb1tzch/1426865152881" ["isUgc"]=> string(4) "true" ["displayName"]=> string(9) "My Design" ["z"]=> string(5) "42500" ["id"]=> string(8) "20081020" } } } }
My function looks like the following:
function get_user_outfit(){
$zwinky_login = $this->curl_post_login();
if($zwinky_login){
$user_outfit = $this->curl_post('http://outfits.zwinky.com/users/' . $this->user_directories() . '/outfits.xml', false, $this->cookie, true, false);
$xml = simplexml_load_string($user_outfit);
$element = $xml->xpath("//outfit[#default=1]");
return $element;
}else{
return 'Could not login.';
}
}
and I can't find a way to translate this into a string.
I've been trying the following http://php.net/manual/en/simplexmlelement.asxml.php which wouldnt work.
Does anyone have a idea?
$xml->xpath(...) returns an array of nodes of the type SimpleXMLElement.
There's built in functions to convert it to a string, although you'll have to loop through the returned nodes.
E.g.
$nodes = $xml->path(...);
$str = '';
foreach($nodes as $node){
$str .= $node->asXML();
}
return $str;
If you want the value of a node, you can invoke the magic method __toString on the SimpleXMLElement object. E.g. echo $node['attribute']; or echo $xml->path('//outfit[#default=1]/some/name')[0];
Alternatively use PHP DOM which gives you a lot more control and flexibility.

Best way to deserialize Json array in php? [duplicate]

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

Extracting triples from text in php using Stanford-NLP?

I have a text .. I went to extract triples from text .. I use Stanford-NLP Library in php Standford-NLP How can I extract triples(subject - object - predicate)?
The example code in the GitHub ReadMe shows how to write the code. The output is a list of word/part-of-speech pairs. Looking at the first example,
"What does the fox say?" becomes:
array(3) {
["wordsAndTags"]=>
array(6) {
[0]=>
array(2) {
[0]=>
string(4) "What"
[1]=>
string(2) "WP"
}
[1]=>
array(2) {
[0]=>
string(4) "does"
[1]=>
string(3) "VBZ"
}
[2]=>
array(2) {
[0]=>
string(3) "the"
[1]=>
string(2) "DT"
}
[3]=>
array(2) {
[0]=>
string(3) "fox"
[1]=>
string(2) "NN"
}
[4]=>
array(2) {
[0]=>
string(3) "say"
[1]=>
string(2) "VB"
}
[5]=>
array(2) {
[0]=>
string(1) "?"
[1]=>
string(1) "."
}
}
["penn"]=>
array(2) {
["parent"]=>
string(4) "ROOT"
["children"]=>
array(1) {
[0]=>
array(2) {
["parent"]=>
string(5) "SBARQ"
["children"]=>
array(3) {
[0]=>
array(2) {
["parent"]=>
string(4) "WHNP"
["children"]=>
array(1) {
[0]=>
array(2) {
["parent"]=>
string(7) "WP What"
["children"]=>
array(0) {
}
}
}
}
[1]=>
array(2) {
["parent"]=>
string(2) "SQ"
["children"]=>
array(3) {
[0]=>
array(2) {
["parent"]=>
string(8) "VBZ does"
["children"]=>
array(0) {
}
}
[1]=>
array(2) {
["parent"]=>
string(2) "NP"
["children"]=>
array(2) {
[0]=>
array(2) {
["parent"]=>
string(6) "DT the"
["children"]=>
array(0) {
}
}
[1]=>
array(2) {
["parent"]=>
string(6) "NN fox"
["children"]=>
array(0) {
}
}
}
}
[2]=>
array(2) {
["parent"]=>
string(2) "VP"
["children"]=>
array(1) {
[0]=>
array(2) {
["parent"]=>
string(6) "VB say"
["children"]=>
array(0) {
}
}
}
}
}
}
[2]=>
array(2) {
["parent"]=>
string(3) ". ?"
["children"]=>
array(0) {
}
}
}
}
}
}
["typedDependencies"]=>
array(5) {
[0]=>
array(3) {
["type"]=>
string(4) "dobj"
[0]=>
array(2) {
["feature"]=>
string(3) "say"
["index"]=>
int(5)
}
[1]=>
array(2) {
["feature"]=>
string(4) "What"
["index"]=>
int(1)
}
}
[1]=>
array(3) {
["type"]=>
string(3) "aux"
[0]=>
array(2) {
["feature"]=>
string(3) "say"
["index"]=>
int(5)
}
[1]=>
array(2) {
["feature"]=>
string(4) "does"
["index"]=>
int(2)
}
}
[2]=>
array(3) {
["type"]=>
string(3) "det"
[0]=>
array(2) {
["feature"]=>
string(3) "fox"
["index"]=>
int(4)
}
[1]=>
array(2) {
["feature"]=>
string(3) "the"
["index"]=>
int(3)
}
}
[3]=>
array(3) {
["type"]=>
string(5) "nsubj"
[0]=>
array(2) {
["feature"]=>
string(3) "say"
["index"]=>
int(5)
}
[1]=>
array(2) {
["feature"]=>
string(3) "fox"
["index"]=>
int(4)
}
}
[4]=>
array(3) {
["type"]=>
string(4) "root"
[0]=>
array(2) {
["feature"]=>
string(4) "ROOT"
["index"]=>
int(0)
}
[1]=>
array(2) {
["feature"]=>
string(3) "say"
["index"]=>
int(5)
}
}
}
}
Then I need to extract triples .. How can I do that?

After Drupal update show Errors

I've updated a Drupal from version 7.2 to version 7.26.
After do that I've some errors:
throw new EntityMalformedException (Missing bundle property on entity of type taxonomy_term)
It appears in file common . inc:
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
I insert some "echos" to see when is shown this message, and I get this:
var_dump( $info['entity keys']);
array(4) {
["id"]=>
string(3) "tid"
["bundle"]=>
string(23) "vocabulary_machine_name"
["label"]=>
string(4) "name"
["revision"]=>
string(0) ""
}
array(4) {
["id"]=>
string(3) "tid"
["bundle"]=>
string(23) "vocabulary_machine_name"
["label"]=>
string(4) "name"
["revision"]=>
string(0) ""
}
var_dump( $info);
array(22) {
["label"]=>
string(22) "Término de taxonomía"
["controller class"]=>
string(22) "TaxonomyTermController"
["base table"]=>
string(18) "taxonomy_term_data"
["uri callback"]=>
string(17) "taxonomy_term_uri"
["fieldable"]=>
bool(true)
["entity keys"]=>
array(4) {
["id"]=>
string(3) "tid"
["bundle"]=>
string(23) "vocabulary_machine_name"
["label"]=>
string(4) "name"
["revision"]=>
string(0) ""
}
["bundle keys"]=>
array(1) {
["bundle"]=>
string(12) "machine_name"
}
["bundles"]=>
array(3) {
["pais"]=>
array(3) {
["label"]=>
string(7) "Regions"
["admin"]=>
array(4) {
["path"]=>
string(58) "admin/structure/taxonomy/%taxonomy_vocabulary_machine_name"
["real path"]=>
string(29) "admin/structure/taxonomy/pais"
["bundle argument"]=>
int(3)
["access arguments"]=>
array(1) {
[0]=>
string(19) "administer taxonomy"
}
}
["rdf_mapping"]=>
array(5) {
["rdftype"]=>
array(1) {
[0]=>
string(12) "skos:Concept"
}
["name"]=>
array(1) {
["predicates"]=>
array(2) {
[0]=>
string(10) "rdfs:label"
[1]=>
string(14) "skos:prefLabel"
}
}
["description"]=>
array(1) {
["predicates"]=>
array(1) {
[0]=>
string(15) "skos:definition"
}
}
["vid"]=>
array(2) {
["predicates"]=>
array(1) {
[0]=>
string(13) "skos:inScheme"
}
["type"]=>
string(3) "rel"
}
["parent"]=>
array(2) {
["predicates"]=>
array(1) {
[0]=>
string(12) "skos:broader"
}
["type"]=>
string(3) "rel"
}
}
}
["auto_created_voc38877"]=>
array(3) {
["label"]=>
string(10) "Provincias"
["admin"]=>
array(4) {
["path"]=>
string(58) "admin/structure/taxonomy/%taxonomy_vocabulary_machine_name"
["real path"]=>
string(46) "admin/structure/taxonomy/auto_created_voc38877"
["bundle argument"]=>
int(3)
["access arguments"]=>
array(1) {
[0]=>
string(19) "administer taxonomy"
}
}
["rdf_mapping"]=>
array(5) {
["rdftype"]=>
array(1) {
[0]=>
string(12) "skos:Concept"
}
["name"]=>
array(1) {
["predicates"]=>
array(2) {
[0]=>
string(10) "rdfs:label"
[1]=>
string(14) "skos:prefLabel"
}
}
["description"]=>
array(1) {
["predicates"]=>
array(1) {
[0]=>
string(15) "skos:definition"
}
}
["vid"]=>
array(2) {
["predicates"]=>
array(1) {
[0]=>
string(13) "skos:inScheme"
}
["type"]=>
string(3) "rel"
}
["parent"]=>
array(2) {
["predicates"]=>
array(1) {
[0]=>
string(12) "skos:broader"
}
["type"]=>
string(3) "rel"
}
}
}
["busquedas_destacadas_"]=>
array(3) {
["label"]=>
string(21) "Búsquedas destacadas"
["admin"]=>
array(4) {
["path"]=>
string(58) "admin/structure/taxonomy/%taxonomy_vocabulary_machine_name"
["real path"]=>
string(46) "admin/structure/taxonomy/busquedas_destacadas_"
["bundle argument"]=>
int(3)
["access arguments"]=>
array(1) {
[0]=>
string(19) "administer taxonomy"
}
}
["rdf_mapping"]=>
array(5) {
["rdftype"]=>
array(1) {
[0]=>
string(12) "skos:Concept"
}
["name"]=>
array(1) {
["predicates"]=>
array(2) {
[0]=>
string(10) "rdfs:label"
[1]=>
string(14) "skos:prefLabel"
}
}
["description"]=>
array(1) {
["predicates"]=>
array(1) {
[0]=>
string(15) "skos:definition"
}
}
["vid"]=>
array(2) {
["predicates"]=>
array(1) {
[0]=>
string(13) "skos:inScheme"
}
["type"]=>
string(3) "rel"
}
["parent"]=>
array(2) {
["predicates"]=>
array(1) {
[0]=>
string(12) "skos:broader"
}
["type"]=>
string(3) "rel"
}
}
}
}
["view modes"]=>
array(1) {
["full"]=>
array(2) {
["label"]=>
string(34) "Página de términos de taxonomía"
["custom settings"]=>
bool(false)
}
}
["static cache"]=>
bool(true)
["field cache"]=>
bool(true)
["load hook"]=>
string(18) "taxonomy_term_load"
["translation"]=>
array(0) {
}
["schema_fields_sql"]=>
array(1) {
["base table"]=>
array(8) {
[0]=>
string(3) "tid"
[1]=>
string(3) "vid"
[2]=>
string(4) "name"
[3]=>
string(11) "description"
[4]=>
string(6) "format"
[5]=>
string(6) "weight"
[6]=>
string(8) "language"
[7]=>
string(9) "i18n_tsid"
}
}
["token type"]=>
string(4) "term"
["access callback"]=>
string(31) "entity_metadata_taxonomy_access"
["creation callback"]=>
string(29) "entity_metadata_create_object"
["save callback"]=>
string(18) "taxonomy_term_save"
["deletion callback"]=>
string(20) "taxonomy_term_delete"
["view callback"]=>
string(27) "entity_metadata_view_single"
["form callback"]=>
string(34) "entity_metadata_form_taxonomy_term"
["configuration"]=>
bool(false)
}
I supposed this is related with something missing in the database. But I can't find it.
Any help, please?
Thanks in advance.

How can I parse stdclass objects from Amazon Product Advertising API?

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].'">';
}

Categories