i have php variables that is like this
var externalData = '<?php echo $matches[0]; ?>';
I when i load the source code of the page comes like this
var externalData = 'data,data,data,data,data
';
this breaks the javascript code, and browser cant run it.
I want to be like this:
var externalData = 'data,data,data,data,data';
the php output is a full line of a file, so may contains the end of the line. I test it by hand and working, how i can fix this?
json_encode(), then parse it client side viaJSON.parse, possibly from a<script type="application/json" id="yourAwesomeId"></script>tag [see this answer].