0
PHP best practice - arrays to javascript
My website has a php array. I want to be able to use the same array in a javscript file. I've done some searching and the best I can come up with is to add this to one of my .php files: ?><script>var jArray = <?php echo json_encode($myPHParray); ?>;</script><?php I've tested this and I'm happy the information is there, however it seems very ugly. Is there a more eloquent way to read PHP from JS?
1 Odpowiedź
- 1
Share your data in myphparay.