The json_encode() PHP function converts PHP data to JSON format data.
Syntax:
json_encode(array);
Example:
<?php
$phpArray = array('user' => "John", 'age' => 22, 'country' => "USA");
$jsonData = json_encode($phpArray);
echo $jsonData;
?>
output:
{"user":"John","age":22,"country":"USA"} |