- json_encode: documentation ( source)
<?php
$content = ["foo" => "bar", "hello" => ["world", "people of the world"], "a" => 1];
$size = strlen(json_encode($content, JSON_NUMERIC_CHECK));
$JSONDATA=
array(
'response' => true,
'error' => null,
'payload' =>
array(
'content' => $content,
'size' => $size
)
);
$joutput = json_encode($JSONDATA,JSON_NUMERIC_CHECK);
echo $joutput;