In this tutorial i will discuss about php json_encode() inbuilt method. json_encode — Returns the JSON representation of a value. In php json_encode() function is an inbuilt function in PHP which is used to convert PHP array or object into JSON representation.
Syntax :
string json_encode( $value, $option, $depth )
Parameters:
JSON_FORCE_OBJECT
, JSON_HEX_QUOT
, JSON_HEX_TAG
, etc. The behaviour of these constants is described on the JSON constants page
// Declare an array
$value = array(
"name"=>"CodeChief",
"email"=>"abc@CodeChief.com");
// Use json_encode() function
$json = json_encode($value);
// Display the output
echo($json);
Output:
Reference: https://www.php.net/manual/en/function.json-encode.php
Hope it can help you.
#json-encode #php