How do you parse JSON with PHP to be able to put individual form answers into individual PHP variables?

  • Profile Image
    jk8conmed
    Asked on December 06, 2013 at 09:18 PM

    I have the PHP Api installed, and I am able to display the JSON as an Array. I just don't understand how to use foreach to spit out the answers individually. Thanks. I know this is basic but this all I really need it to do. 

     

    I have:

     

     $form= $jotformAPI->getFormSubmissions("xxxxxxxxxxxxxxxxx");

     

  • Profile Image
    EltonCris
    Answered on December 06, 2013 at 10:42 PM

    Hi there,

    Example if you have the following response,

    You can write;

    $form= $jotformAPI->getFormSubmissions("xxxxxxxxxxxxxxxxx");

    $form['id'] //this will get the Submissions ID

    $form['form_id'] //this will get the form ID

    $form['answers'][3] //get the submissions 3 array.

    It would be pretty easy if you could dump the data into a php array so you can easily identify the array keys. Just use var_dump($form) to dump the data.

    You can also find out more examples here: http://developers.jotform.com/libraries#jotform-api-php

    Thanks!

  • Profile Image
    jk8conmed
    Answered on December 06, 2013 at 11:25 PM

    Sorry, I know this is rudimentary. 

    but 

      echo $form['id'];

      echo $form['form_id'];

     

    doesn't return anything.

  • Profile Image
    jk8conmed
    Answered on December 06, 2013 at 11:57 PM

    nevermind! I figured it out!