Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

convert php array to javascript array

<?php
    $vegetables = ['apple', 'strawberry', 'banana'];
?>

<script>
var arr = "<?php echo implode(",", $vegetables); ?>".split(",");
console.log(arr); //["apple", "strawberry", "banana"]
Vue.component('#app7', {
    props: arr,
    template: '<li>{{ item.text }}</li>'
})

</script>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #php #array #javascript #array
ADD COMMENT
Topic
Name
6+3 =