xxxxxxxxxx
$person = array(
"dim" => "2*2",
"coloris" => "rouge"
);
$personJSON=json_encode($person);//returns JSON string
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);
?>
xxxxxxxxxx
$person = array(
"name" => "Johny Carson",
"title" => "CTO"
);
$personJSON=json_encode($person);//returns JSON string
=====================================================
$function = "#!!function(){}!!#";
$message = "Hello";
$json = array(
'message' => $message,
'func' => $function
);
$string = json_encode($json);
$string = str_replace('"#!!','',$string);
$string = str_replace('!!#"','',$string);
echo $string;
xxxxxxxxxx
$data = array(
"name" => "John",
"age" => 30,
"city" => "New York"
);
$jsonString = json_encode($data);
echo $jsonString;