Laravel use decoded JSON data as PHP Object -


i want use decoded json data php objects able used follows:

return $data->title 

however im running few errors. able connect remote api url , requested data.

$api        = 'https://remote.api.url/dataset/list'; $json       = file_get_contents($api); $data       = json_decode($json, true);  dd($data); 

when die , dump data see following:

array:1 [▼   "data" => array:5 [▼     0 => array:5 [▼       "id" => "qk4gtmb8"       "title" => "ssa's palliative care has mhealth deficit "       "image" => "http://gstatic.acfee.org/akamaihd/i/52fdb957187"       "published_at" => "2016-06-10 08:05:00"       "created_at" => array:3 [▼         "date" => "2016-06-07 05:48:34.000000"         "timezone_type" => 3         "timezone" => "utc"       ]     ]     1 => array:5 [▶]     2 => array:5 [▶]     3 => array:5 [▶]     4 => array:5 [▶]   ] ] 

but unable use recieved data in object form. return $data->title;

i pretty new json appreciated. in advance.

the second parameter of json_decode (which in case true) converts objects array. official php docs: when true, returned objects converted associative arrays. if remove should ok.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -