Why does var_dump return null?

why does var_dump return null of a decoded json object while print_f works fine?

Cannot help you with any code you tried without having all the code needed to reproduce the problem. You are either using the statement incorrectly, in a different program scope, or at a point where the data doesn’t exist.

I have two json-objects which looks exactly the same but with different data.
I just realized that var_dump works in One of them but not on the other one. The problem should therefore be something with the data itself, but what?

Post the code. Your speculations are of no use to us.

Here is the 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));

What is the real problem you are trying to solve with this code? All I see is you jumping in and out of encoding/decoding. What is the high level overview of what you have going on?

Sponsor our Newsletter | Privacy Policy | Terms of Service