I have 2 json objects that looks exactly the same but with different data. var_dumping one of them returns null while print_r works fine. Why is that so?
the other json-object works fine with both print_r and var_dump.
I think the problem is the data of one of the objects but i still dont get what the specific problem is
[CODE]
<?php
error_reporting(E_ALL);
ini_set(‘display_errors’, 1);
$url = “”;
$xml = simplexml_load_file($url);
$json = json_encode($xml);
$array = json_decode($json,true);
$obj = (object) [
‘data’ => [
],
];
$obj = json_encode($obj);
$obj = json_decode($obj, true);
$obj[‘data’][0] = [ (object) [
‘place’ => ”,
‘events’ => []]];
$obj = json_encode($obj);
$obj = json_decode($obj, true);
for($i=0; $i<$size; $i++){
………
gather the data
………
$obj[‘data’][0][0][‘events’][$i] = (object) [
‘starts’=> $starts,
‘ends’ => $ends,
‘info’ => $info
];
}
$obj = json_encode($obj);
var_dump(json_decode($obj, true));