Home > Article > Backend Development > 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>
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!