I have a php variable called $usershours that contains an array, and I want to echo it inside Javascript code. How do I do that?
I tried This, but it didn’t work:
$usershours = "
data.addRow([ new Date(2012,4,1),50119]).+'<br>+'.
data.addRow([ new Date(2012,4,2),242575])";
<script type="text/javascript">
document.write($arrayholder);
</script>
I want the output to be like this:
data.addRow([ new Date(2012,4,1),50119])
data.addRow([ new Date(2012,4,2),242575])
PS – I need this format because This is the format that Google charts API accept to render charts correctly.
From what I gather, you want this code run by javascript on the client machine:
Simply: