source :<?php // php array $fruits = array('apple', 'orange', 'mango', 'banana', 'strawberry'); ?>
<script type="text/javascript"> // use php implode function to build string for JavaScript array literal var fruits = <?php echo '["' . implode('", "', $fruits) . '"]' ?>; // ["apple", "orange", "mango", "banana", "strawberry"] </script>
https://www.dyn-web.com/tutorials/php-js/array.php
No comments:
Post a Comment