简体   繁体   中英

How to create javascript array from database by php

I want to create a javascript array from databse like this:

var m = [
[one]
[two]
[three]
]

it is important that typeof m be object.

Use Json_encode

$phparray; // This is your php array 

$jsArray = <?php echo json_encode($phparray); ?>;

//do stuff with $jsArray now 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM