"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Convert a MySQL Result Array to JSON in PHP?

How to Convert a MySQL Result Array to JSON in PHP?

Published on 2024-11-07
Browse:625

How to Convert a MySQL Result Array to JSON in PHP?

Converting MySQL Result Array to JSON

In PHP, you can easily convert a MySQL result array to JSON format using json_encode(). This function is available in PHP versions 5.2.0 and later.

To convert a PHP result array, $row, to JSON, simply use the following code:

echo json_encode($row);

The generated JSON data can then be passed to your jQuery plugin as needed.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3