Hi all,
I'm posting JSON to an API call. If I use a var_dump within the API it will return correctly, although if I try to var_dump within the function it will return NULL.
API:
$json = file_get_contents('php://input');
if(isset($_GET['form_id']) && intval($_GET['form_id'])>0)
{
if(isset($json))
{
$records = $questionnaire->logFormAnswers($_POST['answers'],$_GET['form_id']);
Then using the logFormAnswers function...
Function:
public function logFormAnswers($answers = "", $form_id = 0)
{
$answers = json_decode($json,true);
var_dump($answers);
The JSON:
[{"question_id":"3","answer":"dsf"},{"question_id":"3","answer":"sdfsdfdsfsd"}]
Eventually, once the JSON has been decoded, it will be inserted into a database within the function.
If anyone can see what I'm doing wrong, any help is appreciated, thanks!