How do I convert PHP Array to JSON?

To convert a PHP array to JSON data string, you can use the json_encode() function. The json_encode() function converts passed PHP objects into JSON formatted strings. You can control the flow of the conversion by passing encoding parameters to the json_encode() function. In this PHP Array to JSON example, we use the json_encode() function to convert a PHP Array to a JSON string. Click Execute to run the Convert PHP Array to JSON String Example online and see the result.
Loading...