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

Susan Sarandon
Release: 2024-11-02 09:51:31
Original
196 people have browsed it

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:

<code class="php">echo json_encode($row);</code>
Copy after login

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

The above is the detailed content of How to Convert a MySQL Result Array to JSON in PHP?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!