<?php
$myVar = json_encode($myArray) ;
?>
Then pass the variable to you javascript:
<script type="text/javascript">
var myJsVar = <?php echo $myvar; ?>
</script>
I do not know Morris charts.. but maybe you can add a service where you can grab dynamically the data from a distant server providing a data source in the config. In this case you could completely separate the php and your js script which would be much cleaner.
Hence your php script is executed on server side before the js code.. it will replace the values in your code before js will use it.
1
solved How to convert a php array of objects to javascrript objects?