json_encode to convert data to stringJson is a data exchange format like XML. You can learn about Json support of PHP here. We will learn about php function json_encode() here. This function is built in higher versions of PHP. To know about support of your PHP version regarding Json you can check the Json Introduction page.
json_encode function takes data and converts them to a string, we call it as Json string. This string format follows a standard so it can be decoded back to its original data form at the receiving end.
Let us start with an array of data. Here is an simple data array in PHP, we will apply json_encode() to this array.
The output of the above code is here.