How to use the values of a PHP variable in an external javascript script

Asked

Viewed 92 times

-1

I want to use vuejs in a system made in php with MVC,

I want to take an accessible array on the page and move to javascrip at the time of the load, so that it manipulates the display. I know you can do this with AJAX, but I think it doesn’t fit very well with the structure of the project, wanted a viable alternative without having to put in a Hidden input or something like

1 answer

1

Put it in a javascript variable that can be accessed in your code:

<script>
    var array = [ <?php echo implode(",", $array); ?> ]
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.