Retrieve JSON value using PHP json_decode -


i'm trying retrieve value json that's returned api, can't seem work out how there! below being returned , how i'm trying access it:

array(1) { ["ticket"]=> array(17) { ["id"]=> int(707078) ["subject"]=> string(6) "werwer" ["replies_count"]=> int(0) ["comments_count"]=> int(0) ["last_activity_at"]=> string(20) "2013-05-03t10:13:52z" ["created_at"]=> string(20) "2013-05-03t10:13:52z" ["unanswered"]=> bool(true) ["archived"]=> bool(false) ["spam"]=> bool(false) ["trash"]=> bool(false) ["summary"]=> string(9) "werewrwer" ["source"]=> array(1) { ["web"]=> string(3) "api" } ["cc"]=> array(0) { } ["labels"]=> array(0) { } ["requester"]=> array(5) { ["id"]=> int(249190) ["email"]=> string(22) "steven@frontpage.co.uk" ["name"]=> string(6) "steven" ["agent"]=> bool(true) ["picture"]=> array(6) { ["thumb20"]=> string(81) "https://secure.gravatar.com/avatar/9baabb86969cbccb6230d298a04f3490.png?r=pg&s=20" ["thumb24"]=> string(81) "https://secure.gravatar.com/avatar/9baabb86969cbccb6230d298a04f3490.png?r=pg&s=24" ["thumb32"]=> string(81) "https://secure.gravatar.com/avatar/9baabb86969cbccb6230d298a04f3490.png?r=pg&s=32" ["thumb48"]=> string(81) "https://secure.gravatar.com/avatar/9baabb86969cbccb6230d298a04f3490.png?r=pg&s=48" ["thumb64"]=> string(81) "https://secure.gravatar.com/avatar/9baabb86969cbccb6230d298a04f3490.png?r=pg&s=64" ["thumb128"]=> string(82) "https://secure.gravatar.com/avatar/9baabb86969cbccb6230d298a04f3490.png?r=pg&s=128" } } ["content"]=> array(4) { ["html"]=> string(9) "werewrwer" ["text"]=> string(9) "werewrwer" ["truncated"]=> bool(false) ["attachments"]=> array(0) { } } ["starred"]=> bool(false) } }  $jsonresponse = json_decode($jsonresponse, true); die($jsonresponse['ticket']['id']); 

you not doing wrong except not paying attention fact type of argument die (an alias exit) matters:

if status string, function prints status before exiting.

if status integer, value used exit status , not printed. exit statuses should in range 0 254, exit status 255 reserved php , shall not used. status 0 used terminate program successfully.

note: php >= 4.2.0 not print status if integer.

so expected behavior if did instead:

echo $jsonresponse['ticket']['id']; die; 

or this:

die((string)$jsonresponse['ticket']['id']); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -