Home  >  Article  >  Backend Development  >  Convert php array to json

Convert php array to json

王林
王林Original
2019-09-12 17:39:584392browse

Convert php array to json

Convert php array to json string? Function used: json_encode()

1. Function used to convert PHP array to JSON format string:

Convert php array to json

2. Example demonstration, define an array

Convert php array to json

3. Encoded into a string in json format

Convert php array to json

4. Output the encoded string in json format

Convert php array to json

5. After saving, view the output string in JSON format in the browser

Convert php array to json

6. Other precautions for using json_encode()

Convert php array to json

above The content is for reference only!

Recommended video tutorial: PHP video tutorial

The above is the detailed content of Convert php array to json. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn