how to convert php array to javascript array

PHP json_encode function convert the data into JSON string , that can store in JavaScript variable


Example 2

below example shows an associative PHP array output into JavaScript using json_encode

JSON_PRETTY_PRINT option as the second argument to json_encode to display the output in a readable format

Leave a Reply

Your email address will not be published. Required fields are marked *