php json_encode add object code example
Example 1: json php
$person = array(
"name" => "KINGASV",
"title" => "CTO"
);
$personJSON=json_encode($person);
$personJSON = '{"name":"KINGASV","title":"CTO"}';
$person = json_decode($personJSON);
echo $person->name;
Example 2: php json_encode
$person = array(
"name" => "Johny Carson",
"title" => "CTO"
);
$personJSON=json_encode($person);
Example 3: convert text file to json php
<?php
header('Content-type: application/json');
echo json_encode( explode("\r\n",file_get_contents('data.txt')) );
?>