TThis tutorial focuses on converting PHP Array to JSON. JSON is used to read data
from the server and display it to the Web. JSON is a text format , and We can
convert any JS Object into a JSON format.
Convert PHP Array To JSON
PHP is capable of handling JSON and it has some built-in functions to handle
them. json_encode() is used to convert objects, arrays in PHP to JSON
format. The PHP json_encode() function returns the string containing a JSON
equivalent of the value passed.
The syntax of json_encode() function as following.
Here's how we need to convert the numerically indexed array into JSON