Answers for "pass php array to javascript"

PHP
1

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>
Posted by: Guest on October-09-2021
2

php array to js

var arrNums = json_encode(<?php echo $arrNums; ?>);
Posted by: Guest on June-22-2020
0

convert a php array into a javascript array

var js_array = [<?php echo '"'.implode('","',  $disabledDaysRange ).'"' ?>];
Posted by: Guest on February-25-2021
1

laravel array to js

var app = @json($array);
Posted by: Guest on May-25-2020

Code answers related to "pass php array to javascript"

Browse Popular Code Answers by Language