xxxxxxxxxx
$pretty=json_encode($foo, JSON_PRETTY_PRINT);
xxxxxxxxxx
$person = array(
"name" => "Johny Carson",
"title" => "CTO"
);
$personJSON=json_encode($person);//returns JSON string
xxxxxxxxxx
<?php
$age = array("Peter"=>35, "Ben"=>37, "Joe"=>43);
echo json_encode($age);
?>