To convert an Array to JSON in PHP, we use json_encode() function. The function is used to encode a value to JSON format
$arr = array('Millie' => 'Eleven','Mike' => 'Finn','Gaten' => 'Dustin','Noah' => 'Will');echo json_encode($arr)."\n";
Output :
{"Millie":"Eleven","Mike":"Finn","Gaten":"Dustin","Noah":"Will"}
Comments
Post a Comment