json_encode in php code example
Example 1: php json encode
$person = array(
"name" => "Johny Carson",
"title" => "CTO"
);
$personJSON=json_encode($person);
Example 2: json_encode()
json_encode(['name' => 'Jake', 'country' => 'Philippines'])
Example 3: php json_encode header detail
$array = array();
$array['Name'] = 'Alex';
$array['Age'] = 37;
$array['Admin'] = TRUE;
$array['Contact'] = array
(
'Site' => "alexwebdevelop.com",
'Phone' => 123456789,
'Address' => NULL
);
$array['Tags'] = array('php', 'web', 'dev');
$json = json_encode($array, JSON_PRETTY_PRINT);
echo '<pre>';
echo $json;
echo '</pre>';