To convert a php array to Javascript array requires the use of 3 json/javascript functions.
json_encode
encodes the php array to JSON string format.encodeURI
escapes any characters in the string which may raise an error and prevent the converting of php array to javascript array. For example encodeURI escapes carriage returns, tabs, new line characters, etc.JSON.parse
function to convert the string to a Javascript object which is what an array is.The php array does not have to be an associative array for this to work.