Fabian Tschullik Fabian Tschullik - 3 years ago 83
JSON Question

PHP append json with $ to http request body

$body->append('{"stage_id": "43"}');


I would like to make the "43" dynamic and use a $variable for the value: How should look the Syntax look like?

Answer Source

You can use just like this:

<?php
    $var = 43;
    $array = array('stage_id'=>$var);
    $json = json_encode($array);
    $body->append($json);
?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download