What causes this error in my code?
$query = $this->db->query(\"SELECT * FROM tour_foreign ORDER BY id desc\");
$data = array();
foreach ($q
here is the solution for similar problem which i was facing while extracting name from user profile facebook json object
$uname=json_encode($userprof);
$uname=json_decode($uname);
echo "Welcome " . $uname -> name ;
Make an object
$obj = json_decode(json_encode($need_to_json));
Show data from this $obj
$obj->{'needed'};
Reference
json_decode() is used to decode a json string to an array/data object. json_encode() creates a json string from an array or data. You are using the wrong function my friend, try json_encode();
I think you want json_encode, not json_decode.
Set decoding to true
Your decoding is not set to true. If you don't have access to set the source to true. The code below will fix it for you.
$WorkingArray = json_decode(json_encode($data),true);
Ok I was running into the same issue. What I failed to notice is that I was using json_decode() instead of using json_encode() so for those who are going to come here please make sure you are using the right function, which is json_encode()
Note: Depends on what you are working on but make sure you are using the right function.