I searched for some methods on the Internet, and finally I adopted the method of using json strings. Suppose there is a php array $arr, the code is as follows: Copy code The code is as follows: // The default script in html5 is javascript, so there is no need to specify script language <br>var arr_js = <?php echo json_encode($arr)?>; <br>< ;/script> <br> </div>