-2

JSON

{"responseCode":200,
"message":"success",
"content":[{"id":"1234",
    "form_id":"221518928596065",
    "ip":"175.123.31.86",
    "created_at":"2022-06-02 00:36:08",
    "status":"ACTIVE",
    "new":"1",
    "flag":"0",
    "notes":"",
    "updated_at":null,
    "answers":{
        "1":{"name":"heading","order":"1","text":"Form","type":"control_head"},
        "2":{"name":"submit2","order":"5","text":"Submit","type":"control_button"},
        "3":{"name":"name","order":"2","sublabels":"{\"prefix\":\"Prefix\",\"first\":\"First Name\",\"middle\":\"Middle Name\",\"last\":\"Last Name\",\"suffix\":\"Suffix\"}","text":"Name","type":"control_fullname","answer":{"first":"fbsbbb","last":"icqwvvev"},"prettyFormat":"fbsbbb icqwvvev"},
        "4":{"name":"email","order":"3","text":"Email","type":"control_email","answer":"xxxx@gmail.com"},
        "5":{"name":"message","order":"4","text":"MESSAGE","type":"control_textarea","answer":"lol"}
        }
    },
        
        {"id":"1234",
            "form_id":"2123",
            "ip":"175.123.31.86",
            "created_at":"2022-06-02 00:22:24",
            "status":"ACTIVE",
            "new":"1",
            "flag":"0",
            "notes":"",
            "updated_at":null,
            "answers":{
                "1":{"name":"heading","order":"1","text":"Form","type":"control_head"},
                "2":{"name":"submit2","order":"5","text":"Submit","type":"control_button"},
                "3":{"name":"name","order":"2","sublabels":"{\"prefix\":\"Prefix\",\"first\":\"First Name\",\"middle\":\"Middle Name\",\"last\":\"Last Name\",\"suffix\":\"Suffix\"}","text":"Name","type":"control_fullname","answer":{"first":"fbsbbb","last":"icqwvvev"},"prettyFormat":"fbsbbb icqwvvev"},
                "4":{"name":"email","order":"3","text":"Email","type":"control_email","answer":"twicelovepravin@gmail.com"},
                "5":{"name":"message","order":"4","text":"MESSAGE","type":"control_textarea","answer":"lol"}
                }
        }
        ],"duration":"46.81ms","resultSet":{"offset":0,"limit":20,"count":12},"limit-left":994

}

How can i only select "id" data only?

<?php

      $filename = "jotformsubmissionid.json";
      $data = file_get_contents($filename); //Read the JSON file in PHP
      $array = json_decode($data, true); //Convert JSON String into PHP Array


      foreach($array as $row) //Extract the Array Values by using Foreach Loop
      {

        echo $row->content[0]->id;
        print_r($row->content[0]->id);
      }

      ?>

when I run this php code will you get the error like:

Warning: Attempt to read property "content" on array in C:\xampp\htdocs\iot_project\jotformsubmission.php on line 9

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\iot_project\jotformsubmission.php on line 9

Warning: Attempt to read property "id" on null in C:\xampp\htdocs\iot_project\jotformsubmission.php on line 9

Warning: Attempt to read property "content" on int in C:\xampp\htdocs\iot_project\jotformsubmission.php on line 14

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\iot_project\jotformsubmission.php on line 14

  • You decode the JSON and the comment shows *Convert JSON String into PHP Array*, the error shows *Attempt to read property "content" on array*, do you think this has anything to do with it? – Nigel Ren Jun 02 '22 at 07:43

0 Answers0