I have a script that get data from a JSON-API.
echo var_dump(json_decode($result, true)); this displays:
hejarray(1) {
["items"]=> array(2) {
["item"]=> array(1) {
[0]=> array(23) {
["newsdeskML"]=> string(3) "2.1"
["type_of_media"]=> string(12) "pressrelease"
["language"]=> string(2) "sv"
["source_id"]=> string(5) "47784"
["source_name"]=> string(24) "Sverige AB"
["pressroom_name"]=> string(24) "Sverige AB"
["pressroom"]=> string(2) "se"
["pressroom_id"]=> string(5) "53128"
["organization_number"]=> string(11) "556052-5833"
["id"]=> string(6) "968485"
["url"]=> string(126) "xx.com"
["published_at"]=> string(19) "2014-03-05 08:08:33" ["created_at"]=> string(19) "2014-03-05 08:08:33"
["updated_at"]=> string(19) "2014-03-05 08:08:34"
["header"]=> string(56) "header header"
["summary"]=> string(277) "text text".........
If i only want to echo the content in ["summary"]=> string(277) "text text" how can this be done?
EDIT Full json reponse, had to remove contest as it's sensetive data:
{
"items":{
"item":[
{
"newsdeskML":"2.1",
"type_of_media":"pressrelease",
"language":"sv",
"source_id":"47784",
"source_name":"",
"pressroom_name":"",
"pressroom":"se",
"pressroom_id":"",
"organization_number":"",
"id":"968485",
"url":"",
"published_at":"2014-03-05 08:08:33",
"created_at":"2014-03-05 08:08:33",
"updated_at":"2014-03-05 08:08:34",
"header":"",
"summary":"",
"body":""
},
{
"related_items":null
}
]
}
}
This gives the same php output i posted at first:
$var = json_decode($result, true); echo var_dump($var);
But echo var_dump($var['items']); gives null